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]

fix strerror(0)


http://austingroupbugs.net/view.php?id=382 states that POSIX requires
strerror(0) to emit a message that indicates success, and not modify
errno to EINVAL.

---
 newlib/ChangeLog              |    4 ++++
 newlib/libc/string/strerror.c |    6 ++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

2011-05-25  Eric Blake  <eblake@redhat.com>

	* libc/string/strerror.c (_strerror_r): Report "Success" for 0.

diff --git a/newlib/libc/string/strerror.c b/newlib/libc/string/strerror.c
index fd6edd9..8852c36 100644
--- a/newlib/libc/string/strerror.c
+++ b/newlib/libc/string/strerror.c
@@ -33,6 +33,9 @@ This implementation of <<strerror>> prints out the
following strings
 for each of the values defined in `<<errno.h>>':

 o+
+o 0
+Success
+
 o E2BIG
 Arg list too long

@@ -361,6 +364,9 @@ _DEFUN (_strerror_r, (ptr, errnum, internal, errptr),

   switch (errnum)
     {
+    case 0:
+      error = "Success";
+      break;
 /* go32 defines EPERM as EACCES */
 #if defined (EPERM) && (!defined (EACCES) || (EPERM != EACCES))
     case EPERM:
-- 
1.7.5.1


-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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