]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Change XPG-compliant strerror_r function to return error code.
authorUlrich Drepper <drepper@gmail.com>
Sat, 25 Dec 2010 18:56:48 +0000 (13:56 -0500)
committerUlrich Drepper <drepper@gmail.com>
Sat, 25 Dec 2010 18:56:48 +0000 (13:56 -0500)
ChangeLog
string/xpg-strerror.c
sysdeps/mach/xpg-strerror.c

index 497de673a0f05dd87aa02808a546a3d635ef2f7f..c29dd53c4725801e2f6c2e842f036980b562c024 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-12-25  Ulrich Drepper  <drepper@gmail.com>
+
+       [BZ #12204]
+       * string/xpg-strerror.c (__xpg_strerror_r): Return error code, not -1.
+       * sysdeps/mach/xpg-strerror.c (__xpg_strerror_r): Likewise.
+
 2010-12-15  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config.h.in (NO_CTORS_DTORS_SECTIONS): Define.
index 5cb56cdfb88128daf050167baa9648619c3952d5..8d898122d1f1ec3b7a1b61471eef8fd739c21729 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2002, 2004
+/* Copyright (C) 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2010
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -39,18 +39,13 @@ __xpg_strerror_r (int errnum, char *buf, size_t buflen)
 {
   if (errnum < 0 || errnum >= _sys_nerr_internal
       || _sys_errlist_internal[errnum] == NULL)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return EINVAL;
+
   const char *estr = (const char *) _(_sys_errlist_internal[errnum]);
   size_t estrlen = strlen (estr) + 1;
 
   if (buflen < estrlen)
-    {
-      __set_errno (ERANGE);
-      return -1;
-    }
+    return ERANGE;
 
   memcpy (buf, estr, estrlen);
   return 0;
index 8d0b31e6002d751427a5803d63bdaeba2b524bb9..efaf0be29111b569bc3f20ed6ab927906b9b21a3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 2000, 2002, 2004
+/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2010
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -53,30 +53,21 @@ __xpg_strerror_r (int errnum, char *buf, size_t buflen)
   code = err_get_code (errnum);
 
   if (system > err_max_system || ! __mach_error_systems[system].bad_sub)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return EINVAL;
 
   es = &__mach_error_systems[system];
 
   if (sub >= es->max_sub)
     estr = (const char *) es->bad_sub;
   else if (code >= es->subsystem[sub].max_code)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return EINVAL;
   else
     estr = (const char *) _(es->subsystem[sub].codes[code]);
 
   size_t estrlen = strlen (estr) + 1;
 
   if (buflen < estrlen)
-    {
-      __set_errno (ERANGE);
-      return -1;
-    }
+    return ERANGE;
 
   memcpy (buf, estr, estrlen);
   return 0;