public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/27430] New: Provide array of errno names (e.g., ENOMEM), similar to strerror(3)
@ 2021-02-16 22:32 alx.manpages at gmail dot com
  2021-02-16 23:00 ` [Bug libc/27430] " schwab@linux-m68k.org
  2021-02-17  9:10 ` alx.manpages at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: alx.manpages at gmail dot com @ 2021-02-16 22:32 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27430

            Bug ID: 27430
           Summary: Provide array of errno names (e.g., ENOMEM), similar
                    to strerror(3)
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: alx.manpages at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

I propose creating a global array with the names of the errno codes.  Something
in the lines of:

static const char *const errno_name[] = {
        [0] = "0",  // A valid string here might be useful. ("0", "OK", ...)
                    // Otherwise, just use NULL, but then user needs to check.
        [E2BIG] = "E2BIG",
        [EACCESS] = "EACCESS",
        [EADDRINUSE] = "EADDRINUSE",
        [EADI] = "EADI",
        [EADV] = "EADV",
        ...
}

I think these are much more precise than the system-dependent and
locale-dependent strings that strerror(3) provides.

Its usage would be very similar to strerror(3):

#include <errno.h>
#include <stdio.h>
#include <string.h>

errno = E2BIG;
printf([%s]: %s\n", errno_name[errno], strerror(errno));


output:
[E2BIG]: Whatever string E2BIG has.


It could have a wrapper function:


static inline const char *errno_name(int err) {
        return __errno_name[err];
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/27430] Provide array of errno names (e.g., ENOMEM), similar to strerror(3)
  2021-02-16 22:32 [Bug libc/27430] New: Provide array of errno names (e.g., ENOMEM), similar to strerror(3) alx.manpages at gmail dot com
@ 2021-02-16 23:00 ` schwab@linux-m68k.org
  2021-02-17  9:10 ` alx.manpages at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2021-02-16 23:00 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27430

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
What's wrong with strerrorname_np?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/27430] Provide array of errno names (e.g., ENOMEM), similar to strerror(3)
  2021-02-16 22:32 [Bug libc/27430] New: Provide array of errno names (e.g., ENOMEM), similar to strerror(3) alx.manpages at gmail dot com
  2021-02-16 23:00 ` [Bug libc/27430] " schwab@linux-m68k.org
@ 2021-02-17  9:10 ` alx.manpages at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: alx.manpages at gmail dot com @ 2021-02-17  9:10 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27430

Alejandro Colomar (man-pages) <alx.manpages at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |NOTABUG

--- Comment #2 from Alejandro Colomar (man-pages) <alx.manpages at gmail dot com> ---
Hi Andreas,

Nothing wrong, it's great!
Just that I did't know about it, and from what I see, not many people knew
about it[1].

Thanks,

Alex

[1]: https://stackoverflow.com/q/19885360/6872717

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-17  9:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 22:32 [Bug libc/27430] New: Provide array of errno names (e.g., ENOMEM), similar to strerror(3) alx.manpages at gmail dot com
2021-02-16 23:00 ` [Bug libc/27430] " schwab@linux-m68k.org
2021-02-17  9:10 ` alx.manpages at gmail dot com

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).