summaryrefslogtreecommitdiff
path: root/stdio-common/errlist.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-08-31 11:53:51 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-09-29 13:56:06 -0300
commitcef95fdc2e4002ee6357d8d40ef73c8d875720e3 (patch)
tree3488240efb523a6cf14a576d0969bf4460373716 /stdio-common/errlist.c
parentdfb8e514cf4d770a9ce4e7858a351b9a2893614d (diff)
downloadglibc-cef95fdc2e4002ee6357d8d40ef73c8d875720e3.tar
glibc-cef95fdc2e4002ee6357d8d40ef73c8d875720e3.tar.gz
glibc-cef95fdc2e4002ee6357d8d40ef73c8d875720e3.tar.bz2
glibc-cef95fdc2e4002ee6357d8d40ef73c8d875720e3.zip
string: Fix strerrorname_np return value [BZ #26555]
It returns the string of the error constant, not its description (as strerrordesc_np). To handle the Hurd error mapping, the ERR_MAP was removed from errlist.h to errlist.c. Also, the testcase test-strerr (added on 325081b9eb2) was not added on the check build neither it builds correctly. This patch also changed it to decouple from errlist.h, the expected return values are added explicitly for both both strerrorname_np and strerrordesc_np directly. Checked on x86_64-linux-gnu and i686-linux-gnu. I also run a make check for i686-gnu.
Diffstat (limited to 'stdio-common/errlist.c')
-rw-r--r--stdio-common/errlist.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/stdio-common/errlist.c b/stdio-common/errlist.c
index d15f13a22a..2ecf121674 100644
--- a/stdio-common/errlist.c
+++ b/stdio-common/errlist.c
@@ -20,9 +20,13 @@
#include <libintl.h>
#include <array_length.h>
+#ifndef ERR_MAP
+# define ERR_MAP(n) n
+#endif
+
const char *const _sys_errlist_internal[] =
{
-#define _S(n, str) [n] = str,
+#define _S(n, str) [ERR_MAP(n)] = str,
#include <errlist.h>
#undef _S
};
@@ -41,20 +45,21 @@ static const union sys_errname_t
{
#define MSGSTRFIELD1(line) str##line
#define MSGSTRFIELD(line) MSGSTRFIELD1(line)
-#define _S(n, str) char MSGSTRFIELD(__LINE__)[sizeof(str)];
+#define _S(n, str) char MSGSTRFIELD(__LINE__)[sizeof(#n)];
#include <errlist.h>
#undef _S
};
char str[0];
} _sys_errname = { {
-#define _S(n, s) s,
+#define _S(n, s) #n,
#include <errlist.h>
#undef _S
} };
static const unsigned short _sys_errnameidx[] =
{
-#define _S(n, s) [n] = offsetof(union sys_errname_t, MSGSTRFIELD(__LINE__)),
+#define _S(n, s) \
+ [ERR_MAP(n)] = offsetof(union sys_errname_t, MSGSTRFIELD(__LINE__)),
#include <errlist.h>
#undef _S
};