Thu Feb 10 00:17:00 GMT 2011
On 02/09/2011 03:43 PM, Eric Blake wrote:
>>> - return strncpy (buffer, (const char *)error, n);
>>> + strncpy (buffer, error, n);
>>> + return strlen (error) >= n ? error : buffer;
>> This looks wrong to me. Glibc guarantees that the copied result in
>> buffer is NUL-terminated, and I'm missing the "Unknown error XXX"
> No. I strongly feel that strerror and strerror_r should return the same
> strings (insofar as possible).
Oh, and I just re-read the glibc man page:
The GNU-specific strerror_r() returns a pointer to a string
the error message. This may be either a pointer to a string
function stores in buf, or a pointer to some (immutable) static
(in which case buf is unused). If the function stores a string
then at most buflen bytes are stored (the string may be
buflen is too small) and the string always includes a
That is, my implementation was wrong, and buf should be left untouched
if it is not the return value. Will fix in v2.
Eric Blake firstname.lastname@example.org +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 619 bytes
Desc: OpenPGP digital signature
More information about the Newlib