[RFC] Consider adding a function to convert error name to errno

Florian Weimer fweimer@redhat.com
Fri May 8 09:04:48 GMT 2026


* Rocket Ma:

> Got it. Then what about return the errno back, instead of writing it
> into a pointer? I have some rationales:
>
> 1. The old interfaces like strerror directly return string, instead of
> writing error desc into a pointer, so directly returning the errno
> preserves the "convention".
> 2. Error names are fixed, while sigal names are not fixed, for
> example, SIGRTMIN+1.
> 3. Directly return the errno reduce some code complexity.
> 4. Errnos are all positive, so returning -1 could indicate error.

C and POSIX require that all predefined macros have positive values.
This doesn't mean that there are no implementations that define
additional errno macros with negative values in some implementations,
which might include -1.  Maybe 0 could be used as the error indicator,
though.

Thanks,
Florian



More information about the Libc-alpha mailing list