public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* strerror_r GNU flavor
@ 2021-11-09 10:33 Jonny Grant
  2021-11-09 12:35 ` Adhemerval Zanella
  0 siblings, 1 reply; 3+ messages in thread
From: Jonny Grant @ 2021-11-09 10:33 UTC (permalink / raw)
  To: GNU C Library

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?

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

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

char * strerror_r (int errnum, char *buf, size_t n)

Cheers
Jonny

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

* Re: strerror_r GNU flavor
  2021-11-09 10:33 strerror_r GNU flavor Jonny Grant
@ 2021-11-09 12:35 ` Adhemerval Zanella
  2021-11-09 22:53   ` Jonny Grant
  0 siblings, 1 reply; 3+ messages in thread
From: Adhemerval Zanella @ 2021-11-09 12:35 UTC (permalink / raw)
  To: Jonny Grant, GNU C Library



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
> 

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

* Re: strerror_r GNU flavor
  2021-11-09 12:35 ` Adhemerval Zanella
@ 2021-11-09 22:53   ` Jonny Grant
  0 siblings, 0 replies; 3+ messages in thread
From: Jonny Grant @ 2021-11-09 22:53 UTC (permalink / raw)
  To: Adhemerval Zanella, GNU C Library



On 09/11/2021 12:35, Adhemerval Zanella wrote:
> 
> 
> 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.

Thank you for your reply clarifying. Feels better to avoid defining _GNU_SOURCE so software is more portable.

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

Would be good to document it. Should I raise a ticket for this somewhere?

>>
>> 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 contex> 
>>
>> char * strerror_r (int errnum, char *buf, size_t n)

To me makes sense for everything to be consistent with the code, and POSIX which both use "buflen".  Of course we all know the compiler only matches the type, there don't need to be any parameter names at all there.

Kind regards
Jonny

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

end of thread, other threads:[~2021-11-09 22:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-09 10:33 strerror_r GNU flavor Jonny Grant
2021-11-09 12:35 ` Adhemerval Zanella
2021-11-09 22:53   ` Jonny Grant

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