mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] pthread_atfork: fix return value on malloc failure
Date: Sun, 13 Nov 2022 12:10:37 -0500	[thread overview]
Message-ID: <20221113171036.GM29905@brightrain.aerifal.cx> (raw)
In-Reply-To: <20221113152023.GE98588@port70.net>

On Sun, Nov 13, 2022 at 04:20:23PM +0100, Szabolcs Nagy wrote:
> * Alexey Izbyshev <izbyshev@ispras.ru> [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 <errno.h>
> >  #include <pthread.h>
> >  #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

      reply	other threads:[~2022-11-13 17:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12 13:31 Alexey Izbyshev
2022-11-13 15:20 ` Szabolcs Nagy
2022-11-13 17:10   ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221113171036.GM29905@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).