bug-gnulib
[Top][All Lists]
Advanced

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

a note about strerror


From: Bruno Haible
Subject: a note about strerror
Date: Tue, 9 Nov 2010 22:02:14 +0100
User-agent: KMail/1.9.9

In POSIX:2008, strerror may fail for an invalid argument. Likewise in
POSIX:2001 and SUSv2 from 1997.

  "Because no return value is reserved to indicate an error, an application
   wishing to check for error situations should set errno to 0, then call
   strerror(), then check errno."

Hardly any program does this checking. Therefore it's good that gnulib's
strerror module guarantees to work around against this pitfall. I'm adding
a comment about it:


2010-11-09  Bruno Haible  <address@hidden>

        * doc/posix-functions/strerror.texi: Add a comment.

--- doc/posix-functions/strerror.texi.orig      Tue Nov  9 21:56:38 2010
+++ doc/posix-functions/strerror.texi   Tue Nov  9 21:56:17 2010
@@ -16,6 +16,8 @@
 This function fails to return a string for out-of-range integers on
 some platforms:
 Solaris 8.
+(This is not a POSIX violation, but can still cause bugs because most programs
+call @code{strerror} without setting and testing @code{errno}.)
 @end itemize
 
 Portability problems not fixed by Gnulib:



reply via email to

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