This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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]

libc-internal strerror_r usage


L.S.,

GLIBC has the exported strerror_r defined as 'weak'. That is nice, because
it opens the possibility for user applications/libraries to augment the
system error list with their own local error messages by overriding the
strerror_r and still use the well known and easy to use perror() (which is
derived from in many other libs), the '%m' format string conversion
specification (printf, syslog and many others) and strerror() for displaying
also the custom error messages.

BUT, then the internal use of strerror_r SHOULD be strerror_r and NOT
__strerror_r, as is the case in glibc-2.3.{2,3} (at least).

Please find below the patch that does just that. It is against 2.3.2, but
should not be much different for 2.3.3. Maybe I've changed too much, but
that is up to you to decide.

-------------------------------------- CUT HERE
---------------------------------------------
--- glibc-2.3.2-200309260658/argp/argp-help.c.orig	2004-07-28
17:03:50.000000000 +0200
+++ glibc-2.3.2-200309260658/argp/argp-help.c	2004-07-28
17:04:30.000000000 +0200
@@ -1821,13 +1821,13 @@
 #ifdef USE_IN_LIBIO
 	      if (_IO_fwide (stream, 0) > 0)
 		__fwprintf (stream, L": %s",
-			    __strerror_r (errnum, buf, sizeof (buf)));
+			    strerror_r (errnum, buf, sizeof (buf)));
 	      else
 #endif
 		{
 		  putc_unlocked (':', stream);
 		  putc_unlocked (' ', stream);
-		  fputs (__strerror_r (errnum, buf, sizeof (buf)), stream);
+		  fputs (strerror_r (errnum, buf, sizeof (buf)), stream);
 		}
 	    }
 
--- glibc-2.3.2-200309260658/assert/assert-perr.c.orig	2004-07-28
17:04:47.000000000 +0200
+++ glibc-2.3.2-200309260658/assert/assert-perr.c	2004-07-28
17:05:02.000000000 +0200
@@ -58,7 +58,7 @@
 		  __progname, __progname[0] ? ": " : "",
 		  file, line,
 		  function ? function : "", function ? ": " : "",
-		  __strerror_r (errnum, errbuf, sizeof errbuf)) >= 0)
+		  strerror_r (errnum, errbuf, sizeof errbuf)) >= 0)
     {
       /* Print the message.  */
 #ifdef USE_IN_LIBIO
--- glibc-2.3.2-200309260658/gmon/gmon.c.orig	2004-07-28
17:06:15.000000000 +0200
+++ glibc-2.3.2-200309260658/gmon/gmon.c	2004-07-28
17:06:29.000000000 +0200
@@ -346,11 +346,11 @@
 #ifdef USE_IN_LIBIO
 	    if (_IO_fwide (stderr, 0) > 0)
 	      __fwprintf (stderr, L"_mcleanup: gmon.out: %s\n",
-			  __strerror_r (errnum, buf, sizeof buf));
+			  strerror_r (errnum, buf, sizeof buf));
 	    else
 #endif
 	      fprintf (stderr, "_mcleanup: gmon.out: %s\n",
-		       __strerror_r (errnum, buf, sizeof buf));
+		       strerror_r (errnum, buf, sizeof buf));
 	    return;
 	  }
       }
--- glibc-2.3.2-200309260658/inet/rcmd.c.orig	2004-07-28
17:07:04.000000000 +0200
+++ glibc-2.3.2-200309260658/inet/rcmd.c	2004-07-28
17:07:14.000000000 +0200
@@ -269,12 +269,12 @@
 #ifdef USE_IN_LIBIO
 		if (_IO_fwide (stderr, 0) > 0)
 			(void)__fwprintf(stderr, L"%s: %s\n", *ahost,
-					 __strerror_r(errno,
+					 strerror_r(errno,
 						      errbuf, sizeof
(errbuf)));
 		else
 #endif
 			(void)fprintf(stderr, "%s: %s\n", *ahost,
-				      __strerror_r(errno,
+				      strerror_r(errno,
 						   errbuf, sizeof
(errbuf)));
 		__sigsetmask(oldmask);
 		return -1;
--- glibc-2.3.2-200309260658/io/getwd.c.orig	2004-07-28
16:57:56.000000000 +0200
+++ glibc-2.3.2-200309260658/io/getwd.c	2004-07-28 16:58:02.000000000 +0200
@@ -42,7 +42,7 @@
     {
       /* We use 1024 here since it should really be enough and because
 	 this is a safe value.  */
-      __strerror_r (errno, buf, 1024);
+      strerror_r (errno, buf, 1024);
       return NULL;
     }
 
--- glibc-2.3.2-200309260658/misc/error.c.orig	2004-07-28
16:58:11.000000000 +0200
+++ glibc-2.3.2-200309260658/misc/error.c	2004-07-28
16:58:38.000000000 +0200
@@ -141,9 +141,9 @@
 #if defined HAVE_STRERROR_R || _LIBC
   char errbuf[1024];
 # if STRERROR_R_CHAR_P || _LIBC
-  s = __strerror_r (errnum, errbuf, sizeof errbuf);
+  s = strerror_r (errnum, errbuf, sizeof errbuf);
 # else
-  if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
+  if (strerror_r (errnum, errbuf, sizeof errbuf) == 0)
     s = errbuf;
   else
     s = 0;
--- glibc-2.3.2-200309260658/stdio-common/perror.c.orig	2004-07-28
16:58:43.000000000 +0200
+++ glibc-2.3.2-200309260658/stdio-common/perror.c	2004-07-28
16:59:00.000000000 +0200
@@ -37,7 +37,7 @@
   else
     colon = ": ";
 
-  errstring = __strerror_r (errnum, buf, sizeof buf);
+  errstring = strerror_r (errnum, buf, sizeof buf);
 
 #ifdef USE_IN_LIBIO
   if (_IO_fwide (fp, 0) > 0)
--- glibc-2.3.2-200309260658/stdio-common/vfprintf.c.orig	2004-07-28
17:07:49.000000000 +0200
+++ glibc-2.3.2-200309260658/stdio-common/vfprintf.c	2004-07-28
17:08:16.000000000 +0200
@@ -957,7 +957,7 @@
     LABEL (form_strerror):
\
       /* Print description of error ERRNO.  */
\
       string =
\
-	(CHAR_T *) __strerror_r (save_errno, (char *) work_buffer,
\
+	(CHAR_T *) strerror_r (save_errno, (char *) work_buffer,
\
 				 sizeof work_buffer);
\
       is_long = 0;		/* This is no wide-char string.  */
\
       goto LABEL (print_string)
--- glibc-2.3.2-200309260658/string/strerror.c.orig	2004-07-28
16:59:10.000000000 +0200
+++ glibc-2.3.2-200309260658/string/strerror.c	2004-07-28
16:59:33.000000000 +0200
@@ -30,7 +30,7 @@
 strerror (errnum)
      int errnum;
 {
-  char *ret = __strerror_r (errnum, NULL, 0);
+  char *ret = strerror_r (errnum, NULL, 0);
   int saved_errno;
 
   if (__builtin_expect (ret != NULL, 1))
@@ -41,5 +41,5 @@
   __set_errno (saved_errno);
   if (buf == NULL)
     return _("Unknown error");
-  return __strerror_r (errnum, buf, 1024);
+  return strerror_r (errnum, buf, 1024);
 }
--- glibc-2.3.2-200309260658/sunrpc/clnt_perr.c.orig	2004-07-28
16:59:51.000000000 +0200
+++ glibc-2.3.2-200309260658/sunrpc/clnt_perr.c	2004-07-28
17:08:30.000000000 +0200
@@ -109,7 +109,7 @@
 
     case RPC_CANTSEND:
     case RPC_CANTRECV:
-      len = sprintf (str, "; errno = %s", __strerror_r (e.re_errno,
+      len = sprintf (str, "; errno = %s", strerror_r (e.re_errno,
 							chrbuf, sizeof
chrbuf));
       str += len;
       break;
@@ -322,7 +322,7 @@
 
     case RPC_SYSTEMERROR:
       cp = stpcpy (stpcpy (cp, " - "),
-		   __strerror_r (ce->cf_error.re_errno,
+		   strerror_r (ce->cf_error.re_errno,
 				 chrbuf, sizeof chrbuf));
       break;
     default:


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