From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 12368 invoked from network); 13 Nov 2022 17:10:51 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 13 Nov 2022 17:10:51 -0000 Received: (qmail 11334 invoked by uid 550); 13 Nov 2022 17:10:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 11302 invoked from network); 13 Nov 2022 17:10:48 -0000 Date: Sun, 13 Nov 2022 12:10:37 -0500 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20221113171036.GM29905@brightrain.aerifal.cx> References: <20221112133101.253026-1-izbyshev@ispras.ru> <20221113152023.GE98588@port70.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221113152023.GE98588@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH] pthread_atfork: fix return value on malloc failure On Sun, Nov 13, 2022 at 04:20:23PM +0100, Szabolcs Nagy wrote: > * Alexey Izbyshev [2022-11-12 16:31:01 +0300]: > > POSIX requires pthread_atfork to report errors via its return value, > > not via errno. The only specified error is ENOMEM. > > this patch looks good. Yes, looks good to me. Taking it with just one style thing changed (not spelled out anywhere): generally source files keep the header for the interface they're defining at the very top, with headers for interfaces they use below that. > > > > --- > > src/thread/pthread_atfork.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/src/thread/pthread_atfork.c b/src/thread/pthread_atfork.c > > index 76497401..2fbe23ca 100644 > > --- a/src/thread/pthread_atfork.c > > +++ b/src/thread/pthread_atfork.c > > @@ -1,3 +1,4 @@ > > +#include > > #include > > #include "libc.h" > > #include "lock.h" > > @@ -34,7 +35,7 @@ void __fork_handler(int who) > > int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) > > { > > struct atfork_funcs *new = malloc(sizeof *new); > > - if (!new) return -1; > > + if (!new) return ENOMEM; > > > > LOCK(lock); > > new->next = funcs; > > -- > > 2.37.2