unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: libc-alpha@sourceware.org
Cc: commit-hurd@gnu.org
Subject: [hurd,commited] hurd: Fix errlist error mapping
Date: Mon, 23 Aug 2021 19:09:26 +0200	[thread overview]
Message-ID: <20210823170926.3253205-1-samuel.thibault@ens-lyon.org> (raw)

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.
---
 stdio-common/errlist.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/stdio-common/errlist.c b/stdio-common/errlist.c
index 928e966b58..d6f667e1ab 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>
-- 
2.32.0


                 reply	other threads:[~2021-08-23 17:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210823170926.3253205-1-samuel.thibault@ens-lyon.org \
    --to=samuel.thibault@ens-lyon.org \
    --cc=commit-hurd@gnu.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).