mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] pthread_atfork: fix return value on malloc failure
Date: Sun, 13 Nov 2022 16:20:23 +0100	[thread overview]
Message-ID: <20221113152023.GE98588@port70.net> (raw)
In-Reply-To: <20221112133101.253026-1-izbyshev@ispras.ru>

* 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.


> ---
>  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 15:20 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 [this message]
2022-11-13 17:10   ` Rich Felker

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=20221113152023.GE98588@port70.net \
    --to=nsz@port70.net \
    --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).