diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-08-23 19:06:49 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-08-23 19:06:49 +0200 |
commit | 5eb3e2c794c3fdd553833af5342740051221479c (patch) | |
tree | 18ab705a673d1cefc5ede0aeee4637be8f159415 /stdio-common | |
parent | c5e4c0dd0fbf11273854869246ab503c49fd6ee3 (diff) | |
download | glibc-5eb3e2c794c3fdd553833af5342740051221479c.zip glibc-5eb3e2c794c3fdd553833af5342740051221479c.tar.gz glibc-5eb3e2c794c3fdd553833af5342740051221479c.tar.bz2 |
hurd: Fix errlist error mapping
On the Hurd, the errno values don't start at 0, so _sys_errlist_internal
needs index remapping. The _sys_errlist_internal definition already properly
uses ERR_MAP, but __get_errlist and __get_errname were not.
Diffstat (limited to 'stdio-common')
-rw-r--r-- | stdio-common/errlist.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/stdio-common/errlist.c b/stdio-common/errlist.c index 928e966..d6f667e 100644 --- a/stdio-common/errlist.c +++ b/stdio-common/errlist.c @@ -34,8 +34,9 @@ const char *const _sys_errlist_internal[] = const char * __get_errlist (int errnum) { - if (errnum >= 0 && errnum < array_length (_sys_errlist_internal)) - return _sys_errlist_internal[errnum]; + int mapped = ERR_MAP (errnum); + if (mapped >= 0 && mapped < array_length (_sys_errlist_internal)) + return _sys_errlist_internal[mapped]; return NULL; } @@ -67,10 +68,11 @@ static const unsigned short _sys_errnameidx[] = const char * __get_errname (int errnum) { - if (errnum < 0 || errnum >= array_length (_sys_errnameidx) - || (errnum > 0 && _sys_errnameidx[errnum] == 0)) + int mapped = ERR_MAP (errnum); + if (mapped < 0 || mapped >= array_length (_sys_errnameidx) + || (mapped > 0 && _sys_errnameidx[mapped] == 0)) return NULL; - return _sys_errname.str + _sys_errnameidx[errnum]; + return _sys_errname.str + _sys_errnameidx[mapped]; } #include <errlist-compat.c> |