From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10331 Path: news.gmane.org!not-for-mail From: Alexander Monakov Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] newlocale: set errno on failure Date: Mon, 25 Jul 2016 12:46:53 +0300 (MSK) 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 Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1469440040 22382 80.91.229.3 (25 Jul 2016 09:47:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Jul 2016 09:47:20 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10344-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jul 25 11:47:15 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 1bRcTi-0001aF-Ga for gllmg-musl@m.gmane.org; Mon, 25 Jul 2016 11:47:14 +0200 Original-Received: (qmail 26504 invoked by uid 550); 25 Jul 2016 09:47:13 -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 26486 invoked from network); 25 Jul 2016 09:47:12 -0000 In-Reply-To: <52B93B58-3345-45E1-B108-C68AA212952F@gmail.com> User-Agent: Alpine 2.20.13 (LNX 116 2015-12-14) Xref: news.gmane.org gmane.linux.lib.musl.general:10331 Archived-At: 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 > #include > #include > #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