This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: strerror_r not according to standard ?


On Mon, May 24, 2010 at 9:38 PM, Eric Blake <eblake@redhat.com> wrote:
> On 05/24/2010 10:04 AM, Vinu Rajashekhar wrote:
>> I have a doubt regarding the newlib implementation of strerror_r.
>
> strerror_r is a can of worms, thanks to the conflict between GNU and
> POSIX definitions.
>
>>
>> The function doesn't set ERANGE if the buflen given is insufficient
>> to store the whole description of the errno. Similarly, it doesn't set
>> EINVAL if errno is not a ?valid error number.
>
> Patches to fix that behavior to be more like glibc would be welcome.
>

I was testing the glibc GNU strerror_r on my system and it seems that the GNU
strerror_r doesn't set errno at all for both EINVAL and ERANGE. The differences
between glibc GNU strerror_r and newlib GNU strerror_r are that -
1) If an immutable static string is returned then glibc strerror_r
doesn't do anything to buffer
2) All strings are null-terminated in the case of glibc strerror_r,
which is a problem, since we
cannot find out if the length given was insufficient !

So I believe what newlib strerror_r is doing right now is ok.

>>
>> Another thing is that it, in the linux manpages it says that strerror_r (the GNU
>> extension) always returns a null-terminated string, which is not the case
>> for the newlib strerror_r.
>
> Again, patches welcome. ?But patches to change things to match the POSIX
> signature would have to be conditionalized, because some newlib clients
> (like cygwin) still want to keep the glibc signature.
>
> --
> Eric Blake ? eblake@redhat.com ? ?+1-801-349-2682
> Libvirt virtualization library http://libvirt.org
>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]