bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tar-1.13.25: HPUX 10.20 strerror_r() broken


From: Harald Koenig
Subject: tar-1.13.25: HPUX 10.20 strerror_r() broken
Date: Fri, 19 Oct 2001 11:52:01 +0200
User-agent: Mutt/1.3.16i

Hi,

the `ignfail' regression test of tar-1.13.25 fails on HPUX 10.20
because strerror_r() returns an "int" and not "char *".
from `man strerror_r' :


      int strerror_r(int errnum, char *buffer, int buflen);
...

      strerror_r() is identical to strerror(), except that the result string
      is passed back in the supplied buffer.  A buffer length of 80 is
      recommended.  If an error is detected or the buffer is of insufficient
      length, -1 is returned.  If the operation is successful, 0 is
      returned.

 Hewlett-Packard Company            - 1 -    HP-UX Release 10.20:  July 1996


since strerror_r() writes to the buffer being passed,
I don't see why to use/print the return value of strerror_r(),
better use the buffer itself, this is more portable:


-------------------------------------------------------------------------------
--- tar-1.13.25/lib/error.c.orig        Fri Oct 19 11:43:27 2001
+++ tar-1.13.25/lib/error.c     Fri Oct 19 11:48:55 2001
@@ -188,13 +188,14 @@
     {
 # if defined HAVE_STRERROR_R || _LIBC
       char errbuf[1024];
-      char *s = __strerror_r (errnum, errbuf, sizeof errbuf);
+      errbuf[0] = 0;
+      __strerror_r (errnum, errbuf, sizeof errbuf);
 #  if _LIBC && USE_IN_LIBIO
       if (_IO_fwide (stderr, 0) > 0)
-       __fwprintf (stderr, L": %s", s);
+       __fwprintf (stderr, L": %s", errbuf);
       else
 #  endif
-       fprintf (stderr, ": %s", s);
+       fprintf (stderr, ": %s", errbuf);
 # else
       fprintf (stderr, ": %s", strerror (errnum));
 # endif
-------------------------------------------------------------------------------



Harald
-- 
"I hope to die                                      ___       _____
before I *have* to use Microsoft Word.",           0--,|    /OOOOOOO\
Donald E. Knuth, 21-09-2001 in Tuebingen.         <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig                                          \/\/\/\/\/\/\/\/\/
science+computing ag                                    //  /     \\  \
address@hidden                            ^^^^^       ^^^^^



reply via email to

[Prev in Thread] Current Thread [Next in Thread]