From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10332 Path: news.gmane.org!not-for-mail From: Julien Ramseier Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] newlocale: set errno on failure Date: Mon, 25 Jul 2016 11:48:50 +0200 Message-ID: References: <52B93B58-3345-45E1-B108-C68AA212952F@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_970B354B-92F1-4522-9403-442DB4CEF29E" X-Trace: ger.gmane.org 1469440149 24154 80.91.229.3 (25 Jul 2016 09:49:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Jul 2016 09:49:09 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10345-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jul 25 11:49:09 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1bRcVY-00031V-HD for gllmg-musl@m.gmane.org; Mon, 25 Jul 2016 11:49:08 +0200 Original-Received: (qmail 28328 invoked by uid 550); 25 Jul 2016 09:49:06 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 28310 invoked from network); 25 Jul 2016 09:49:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:message-id:mime-version:subject:date:references:to:in-reply-to; bh=gVXFg+M5tPwX9kbT04U+iKG8Z6bXcywGauZZSGuH93Q=; b=Ormi2pBiW4GCK6ehYaPNbnYEhceAA4MWBV9Oaf9qGHAg1eURiqDMqewZuWC51z4hRe lb64cXhRyYXeSFW3QN7ezONWNeFo9kj22xd22E28ClYN6yDsxPBqU8GK0lWJM1tyk6Vx uLgSgPXM7d+p0TaqMvpydav1wciWiFDBZKO+Eqv9lEdrTlmed+2/mh+goW4KStJ9NZvJ g1kj5JfgS+yIJlU819GrM2CUDOpCoFZvdT/4Jc/bzHEckx8l+PfuL7Uff9itJXv3JImE q+hfd/ZocKuTNMT8EAAhmFNxBdhfiS9kdVT2ZmI9WuugfqRi6la89ahY/TYO8g9ad4AV DIwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:mime-version:subject:date :references:to:in-reply-to; bh=gVXFg+M5tPwX9kbT04U+iKG8Z6bXcywGauZZSGuH93Q=; b=DEhRVtMXhxecJYTibTT7gycgfA4nJdOgDGWqHUsMP5EtB230exbhN+tg8DOYulCjUX vKqo6syRQz4/b4a+bLnrT/QuXfbRF5ZnQVaI92K50jGVvFG+UyYTX13P3hLsf09RsS37 09usXLEMQuTTC2SW5b/s/zroHeYa0lqHviOgmJaFn+n4SCTzSU7KhWwv8k0fokQ8lML8 DI6zOvLd4Y5TKsOTJwDqLwRUHez+bMD9Yk43c/CLPID90uVCrTgi+iY0DIahZz9h0NOH aZHtexdZaiA+/2sBTymcpdhAIDB8RPW9iOCe7Xs0NvEDM1O34ClVxznCjjV6cj0HyBud SPRA== X-Gm-Message-State: AEkoouttQ6s2bSCpHVp5GcGHAZOROi3kN+KU0uyDbxe2wtkZkuDeXfG8fShZ75bYNCSm0w== X-Received: by 10.28.223.9 with SMTP id w9mr18094074wmg.65.1469440134021; Mon, 25 Jul 2016 02:48:54 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3112) Xref: news.gmane.org gmane.linux.lib.musl.general:10332 Archived-At: --Apple-Mail=_970B354B-92F1-4522-9403-442DB4CEF29E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Oops I did miss that. Sorry for the noise. - Julien > Le 25 juil. 2016 =C3=A0 11:46, Alexander Monakov = a =C3=A9crit : >=20 > On Mon, 25 Jul 2016, Julien Ramseier wrote: >> As per POSIX, newlocale() should set errno when it fails. >>=20 >> --- >> src/locale/newlocale.c | 2 ++ >> 1 file changed, 2 insertions(+) >>=20 >> 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 >> #include >> #include >> #include "locale_impl.h" >> @@ -42,6 +43,7 @@ locale_t __newlocale(int mask, const char *name, = locale_t loc) >> return UTF8_LOCALE; >>=20 >> if ((loc =3D malloc(sizeof *loc))) *loc =3D tmp; >> + else errno =3D ENOMEM; >=20 > When malloc returns NULL, it will set errno to ENOMEM; there's no need = for > callers to handle that separately. >=20 > Did you hit some issue in practice that prompted this change? >=20 > Alexander --Apple-Mail=_970B354B-92F1-4522-9403-442DB4CEF29E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Oops I did miss that.
Sorry for the = noise.

- = Julien

Le 25 juil. 2016 =C3=A0 11:46, Alexander = Monakov <amonakov@ispras.ru> a =C3=A9crit :

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 = =3D malloc(sizeof *loc))) *loc =3D tmp;
+ else = errno =3D 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

= --Apple-Mail=_970B354B-92F1-4522-9403-442DB4CEF29E--