strerror_r GNU flavor

Adhemerval Zanella adhemerval.zanella@linaro.org
Tue Nov 9 12:35:26 GMT 2021



On 09/11/2021 07:33, Jonny Grant wrote:
> Hello
> 
> Is it better to depreciate the GNU flavor of strerror_r now that there is a POSIX version?
> 
> I was reading "string.h" and the man page:
> 
> https://man7.org/linux/man-pages/man3/strerror.3.html
> 
> The man page does state :-
> 
> "The XSI-compliant strerror_r() is preferred for portable
> applications.  It returns the error string in the user-supplied
> buffer buf of length buflen."
> 
> Keeping the GNU version sounds reasonable, but at least marking it depreciated?

The main problem is the GNU version is the one exported with _GNU_SOURCE.
It means to favor the XPG would require to export it as _GNU_SOURCE, which
leads to more potential breakage (since for programs that use _GNU_SOURCE
is likely to be troublesome to disable it). This is not a worthwhile change
and is definitely an *API* break.

> 
> Some other queries :-
> I noticed this page does not include the POSIX version of strerror_r
> 
> https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html

Usually the manual favor on GNU extension, but I don't think this prevent
us to document POSIX functions as well.

> 
> Also, this page function definition says "size_t n" instead of the expected "size_t buflen", should that be changed? 

The variable name is meaningless in this context.

> 
> char * strerror_r (int errnum, char *buf, size_t n)
> 
> Cheers
> Jonny
> 


More information about the Libc-alpha mailing list