From: Alexander Monakov <amonakov@ispras.ru>
To: musl@lists.openwall.com
Subject: Re: [PATCH] newlocale: set errno on failure
Date: Mon, 25 Jul 2016 12:46:53 +0300 (MSK) [thread overview]
Message-ID: <alpine.LNX.2.20.13.1607251243030.19688@monopod.intra.ispras.ru> (raw)
In-Reply-To: <52B93B58-3345-45E1-B108-C68AA212952F@gmail.com>
On Mon, 25 Jul 2016, Julien Ramseier wrote:
> As per POSIX, newlocale() should set errno when it fails.
>
> ---
> src/locale/newlocale.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/src/locale/newlocale.c b/src/locale/newlocale.c
> index f50bbe9..2bfb832 100644
> --- a/src/locale/newlocale.c
> +++ b/src/locale/newlocale.c
> @@ -1,3 +1,4 @@
> +#include <errno.h>
> #include <stdlib.h>
> #include <string.h>
> #include "locale_impl.h"
> @@ -42,6 +43,7 @@ locale_t __newlocale(int mask, const char *name, locale_t loc)
> return UTF8_LOCALE;
>
> if ((loc = malloc(sizeof *loc))) *loc = tmp;
> + else errno = ENOMEM;
When malloc returns NULL, it will set errno to ENOMEM; there's no need for
callers to handle that separately.
Did you hit some issue in practice that prompted this change?
Alexander
next prev parent reply other threads:[~2016-07-25 9:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-25 9:35 Julien Ramseier
2016-07-25 9:46 ` Alexander Monakov [this message]
2016-07-25 9:48 ` Julien Ramseier
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=alpine.LNX.2.20.13.1607251243030.19688@monopod.intra.ispras.ru \
--to=amonakov@ispras.ru \
--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).