Bug in strerror_r

Eric Blake ericblake@comcast.net
Thu Mar 17 17:24:00 GMT 2005

POSIX requires strerror_r to return an int: 0 for success, and an errno value failure.  Newlib currently returns char*, (the value of strerror), which is not permitted.  See http://www.opengroup.org/onlinepubs/009695399/functions/strerror_r.html.

I'm not sure if libc/sys/linux/dl has problems, since its Makefile.am includes AM_CFLAGS of -D__strerror_r=strerror_r, so that should also be visited.  Also, strerror in general is not required to be reentrant, but strerror_r is, so I am relying on the documentation of newlib's strerror being thread-safe since (with or without the patch) this implementation of strerror_r calls strerror.  Therefore, this patch may not be complete, but it is a start.

2005-03-17  Eric Blake  <ebb9@byu.net>

	* libc/string/strerror_r.c (strerror_r): Return int, not char*,
	as required by POSIX.
	* libc/include/string.h (strerror_r): Ditto.
	* libc/sys/linux/argp/argp-help.c (__argp_failure): Fix caller.

Eric Blake
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newlib.patch
Type: application/octet-stream
Size: 3567 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20050317/f57a20af/attachment.obj>

More information about the Newlib mailing list