public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/vineet/arc-port-latest] hurd: Fix strerror not setting errno
@ 2020-07-09 16:36 Vineet Gupta
0 siblings, 0 replies; only message in thread
From: Vineet Gupta @ 2020-07-09 16:36 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=01ac385ca819599f7f1815115ffe926b5e1460ef
commit 01ac385ca819599f7f1815115ffe926b5e1460ef
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Tue Jul 7 21:46:53 2020 +0000
hurd: Fix strerror not setting errno
* sysdeps/mach/strerror_l.c: Include <errno.h>.
(__strerror_l): Save errno on entry and restore it on exit.
Diff:
---
sysdeps/mach/strerror_l.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/sysdeps/mach/strerror_l.c b/sysdeps/mach/strerror_l.c
index 72b857f4a0..dacb7e4d95 100644
--- a/sysdeps/mach/strerror_l.c
+++ b/sysdeps/mach/strerror_l.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <mach/error.h>
#include <errorlib.h>
#include <tls-internal.h>
@@ -40,6 +41,8 @@ translate (const char *str, locale_t loc)
char *
__strerror_l (int errnum, locale_t loc)
{
+ int saved_errno = errno;
+ char *err;
int system;
int sub;
int code;
@@ -61,15 +64,15 @@ __strerror_l (int errnum, locale_t loc)
errnum) == -1)
tls_internal->strerror_l_buf = NULL;
+ __set_errno (saved_errno);
return tls_internal->strerror_l_buf;
}
es = &__mach_error_systems[system];
if (sub >= es->max_sub)
- return (char *) translate (es->bad_sub, loc);
-
- if (code >= es->subsystem[sub].max_code)
+ err = (char *) translate (es->bad_sub, loc);
+ else if (code >= es->subsystem[sub].max_code)
{
struct tls_internal_t *tls_internal = __glibc_tls_internal ();
free (tls_internal->strerror_l_buf);
@@ -79,10 +82,13 @@ __strerror_l (int errnum, locale_t loc)
errnum) == -1)
tls_internal->strerror_l_buf = NULL;
- return tls_internal->strerror_l_buf;
+ err = tls_internal->strerror_l_buf;
}
+ else
+ err = (char *) translate (es->subsystem[sub].codes[code], loc);
- return (char *) translate (es->subsystem[sub].codes[code], loc);
+ __set_errno (saved_errno);
+ return err;
}
weak_alias (__strerror_l, strerror_l)
libc_hidden_def (__strerror_l)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-07-09 16:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 16:36 [glibc/vineet/arc-port-latest] hurd: Fix strerror not setting errno Vineet Gupta
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 read-only IMAP folder(s) and NNTP newsgroup(s).