mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-12 20:20:18 +00:00
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.
This commit is contained in:
parent
5549370a73
commit
01ac385ca8
@ -21,6 +21,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <mach/error.h>
|
#include <mach/error.h>
|
||||||
#include <errorlib.h>
|
#include <errorlib.h>
|
||||||
#include <tls-internal.h>
|
#include <tls-internal.h>
|
||||||
@ -40,6 +41,8 @@ translate (const char *str, locale_t loc)
|
|||||||
char *
|
char *
|
||||||
__strerror_l (int errnum, locale_t loc)
|
__strerror_l (int errnum, locale_t loc)
|
||||||
{
|
{
|
||||||
|
int saved_errno = errno;
|
||||||
|
char *err;
|
||||||
int system;
|
int system;
|
||||||
int sub;
|
int sub;
|
||||||
int code;
|
int code;
|
||||||
@ -61,15 +64,15 @@ __strerror_l (int errnum, locale_t loc)
|
|||||||
errnum) == -1)
|
errnum) == -1)
|
||||||
tls_internal->strerror_l_buf = NULL;
|
tls_internal->strerror_l_buf = NULL;
|
||||||
|
|
||||||
|
__set_errno (saved_errno);
|
||||||
return tls_internal->strerror_l_buf;
|
return tls_internal->strerror_l_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
es = &__mach_error_systems[system];
|
es = &__mach_error_systems[system];
|
||||||
|
|
||||||
if (sub >= es->max_sub)
|
if (sub >= es->max_sub)
|
||||||
return (char *) translate (es->bad_sub, loc);
|
err = (char *) translate (es->bad_sub, loc);
|
||||||
|
else if (code >= es->subsystem[sub].max_code)
|
||||||
if (code >= es->subsystem[sub].max_code)
|
|
||||||
{
|
{
|
||||||
struct tls_internal_t *tls_internal = __glibc_tls_internal ();
|
struct tls_internal_t *tls_internal = __glibc_tls_internal ();
|
||||||
free (tls_internal->strerror_l_buf);
|
free (tls_internal->strerror_l_buf);
|
||||||
@ -79,10 +82,13 @@ __strerror_l (int errnum, locale_t loc)
|
|||||||
errnum) == -1)
|
errnum) == -1)
|
||||||
tls_internal->strerror_l_buf = NULL;
|
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)
|
weak_alias (__strerror_l, strerror_l)
|
||||||
libc_hidden_def (__strerror_l)
|
libc_hidden_def (__strerror_l)
|
||||||
|
Loading…
Reference in New Issue
Block a user