strerror_r questions

Eric Blake eblake@redhat.com
Thu Feb 10 00:29:00 GMT 2011


On 02/09/2011 03:43 PM, Eric Blake wrote:
>> Erm... shouldn't the return value be "int" rather than "char *" in this
>> case?
> 
> Oops, yes.  Will fix in v2.

Changes in v2: more documentation, fix the signature, change the default
when no feature macros are defined, don't overwrite buf if n is too
small, guarantee NUL termination in POSIX variant

> The "Unknown error XXX" message is a cygwin artifact, not a newlib
> artifact.  That is, cygwin should be using it's own strerror_r, since it
> provides its own strerror() with different behavior than newlib's.

Surprisingly, cygwin can continue to use newlib's strerror_r, but not
its __xpg_strerror_r.

---
 newlib/ChangeLog                    |   11 ++++++++
 newlib/libc/include/string.h        |   15 ++++++++++-
 newlib/libc/string/Makefile.am      |    3 +-
 newlib/libc/string/Makefile.in      |   14 ++++++++--
 newlib/libc/string/strerror.c       |   14 ++++++++++
 newlib/libc/string/strerror_r.c     |   46
++++++++++++++++++++++++++++------
 newlib/libc/string/xpg_strerror_r.c |   25 +++++++++++++++++++
 7 files changed, 115 insertions(+), 13 deletions(-)
 create mode 100644 newlib/libc/string/xpg_strerror_r.c

2011-02-09  Eric Blake  <eblake@redhat.com>

	* libc/include/string.h (strerror_r): Update declaration.
	* libc/string/strerror.c (strerror): Update documentation.
	* libc/string/strerror_r.c (strerror_r): Always return
	NUL-terminated string; don't overwrite too-short buf.
	* libc/string/xpg_strerror_r.c (__xpg_strerror_r): Implement
	POSIX variant.
	* libc/string/Makefile.am (GENERAL_SOURCES): Build new file.
	* libc/string/Makefile.in: Regenerate.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: newlib.patch48
URL: <http://sourceware.org/pipermail/newlib/attachments/20110210/4d1c3530/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20110210/4d1c3530/attachment.sig>


More information about the Newlib mailing list