]> Savannah Git Hosting - gnulib.git/commitdiff
strerror-override: Fix possible compilation error.
authorBruno Haible <bruno@clisp.org>
Tue, 29 Jun 2021 00:17:30 +0000 (02:17 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 29 Jun 2021 00:19:32 +0000 (02:19 +0200)
Reported by Thomas Klausner <wiz@netbsd.org>.

* lib/strerror-override.h (GNULIB_defined_strerror_override_macro): New
macro.
* lib/strerror-override.c (strerror_override): Don't define if
GNULIB_defined_strerror_override_macro is set.

ChangeLog
lib/strerror-override.c
lib/strerror-override.h

index ace8ade4c63c089f197414f7d268a735ddcf81ea..05f196a933c9c0889de552acbf2f438989641527 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-06-28  Bruno Haible  <bruno@clisp.org>
+
+       strerror-override: Fix possible compilation error.
+       Reported by Thomas Klausner <wiz@netbsd.org>.
+       * lib/strerror-override.h (GNULIB_defined_strerror_override_macro): New
+       macro.
+       * lib/strerror-override.c (strerror_override): Don't define if
+       GNULIB_defined_strerror_override_macro is set.
+
 2021-06-27  Bruno Haible  <bruno@clisp.org>
 
        environ: Fix wrong autoconf test result in C++ mode.
index 172a1d3d763c79c97ed977391218fbdbfcf8a2ef..e76d55dbafc10d188b495b5f2fd1360b8a8af0fd 100644 (file)
@@ -29,6 +29,8 @@
 # endif
 #endif
 
+#if !GNULIB_defined_strerror_override_macro
+
 /* If ERRNUM maps to an errno value defined by gnulib, return a string
    describing the error.  Otherwise return NULL.  */
 const char *
@@ -37,12 +39,12 @@ strerror_override (int errnum)
   /* These error messages are taken from glibc/sysdeps/gnu/errlist.c.  */
   switch (errnum)
     {
-#if REPLACE_STRERROR_0
+# if REPLACE_STRERROR_0
     case 0:
       return "Success";
-#endif
+# endif
 
-#if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
+# if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
     case EINPROGRESS:
       return "Operation now in progress";
     case EALREADY:
@@ -89,8 +91,8 @@ strerror_override (int errnum)
       return "No route to host";
     case EWOULDBLOCK:
       return "Operation would block";
-#endif
-#if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
+# endif
+# if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
     case ETXTBSY:
       return "Text file busy";
     case ENODATA:
@@ -103,8 +105,8 @@ strerror_override (int errnum)
       return "Timer expired";
     case EOTHER:
       return "Other error";
-#endif
-#if GNULIB_defined_EWINSOCK /* native Windows platforms */
+# endif
+# if GNULIB_defined_EWINSOCK /* native Windows platforms */
     case ESOCKTNOSUPPORT:
       return "Socket type not supported";
     case EPFNOSUPPORT:
@@ -125,7 +127,7 @@ strerror_override (int errnum)
       return "Stale NFS file handle";
     case EREMOTE:
       return "Object is remote";
-# if HAVE_WINSOCK2_H
+#  if HAVE_WINSOCK2_H
       /* WSA_INVALID_HANDLE maps to EBADF */
       /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
       /* WSA_INVALID_PARAMETER maps to EINVAL */
@@ -213,90 +215,92 @@ strerror_override (int errnum)
     case WSANO_DATA:
       return "Valid name, no data record of requested type";
       /* WSA_QOS_* omitted */
+#  endif
 # endif
-#endif
 
-#if GNULIB_defined_ENOMSG
+# if GNULIB_defined_ENOMSG
     case ENOMSG:
       return "No message of desired type";
-#endif
+# endif
 
-#if GNULIB_defined_EIDRM
+# if GNULIB_defined_EIDRM
     case EIDRM:
       return "Identifier removed";
-#endif
+# endif
 
-#if GNULIB_defined_ENOLINK
+# if GNULIB_defined_ENOLINK
     case ENOLINK:
       return "Link has been severed";
-#endif
+# endif
 
-#if GNULIB_defined_EPROTO
+# if GNULIB_defined_EPROTO
     case EPROTO:
       return "Protocol error";
-#endif
+# endif
 
-#if GNULIB_defined_EMULTIHOP
+# if GNULIB_defined_EMULTIHOP
     case EMULTIHOP:
       return "Multihop attempted";
-#endif
+# endif
 
-#if GNULIB_defined_EBADMSG
+# if GNULIB_defined_EBADMSG
     case EBADMSG:
       return "Bad message";
-#endif
+# endif
 
-#if GNULIB_defined_EOVERFLOW
+# if GNULIB_defined_EOVERFLOW
     case EOVERFLOW:
       return "Value too large for defined data type";
-#endif
+# endif
 
-#if GNULIB_defined_ENOTSUP
+# if GNULIB_defined_ENOTSUP
     case ENOTSUP:
       return "Not supported";
-#endif
+# endif
 
-#if GNULIB_defined_ENETRESET
+# if GNULIB_defined_ENETRESET
     case ENETRESET:
       return "Network dropped connection on reset";
-#endif
+# endif
 
-#if GNULIB_defined_ECONNABORTED
+# if GNULIB_defined_ECONNABORTED
     case ECONNABORTED:
       return "Software caused connection abort";
-#endif
+# endif
 
-#if GNULIB_defined_ESTALE
+# if GNULIB_defined_ESTALE
     case ESTALE:
       return "Stale NFS file handle";
-#endif
+# endif
 
-#if GNULIB_defined_EDQUOT
+# if GNULIB_defined_EDQUOT
     case EDQUOT:
       return "Disk quota exceeded";
-#endif
+# endif
 
-#if GNULIB_defined_ECANCELED
+# if GNULIB_defined_ECANCELED
     case ECANCELED:
       return "Operation canceled";
-#endif
+# endif
 
-#if GNULIB_defined_EOWNERDEAD
+# if GNULIB_defined_EOWNERDEAD
     case EOWNERDEAD:
       return "Owner died";
-#endif
+# endif
 
-#if GNULIB_defined_ENOTRECOVERABLE
+# if GNULIB_defined_ENOTRECOVERABLE
     case ENOTRECOVERABLE:
       return "State not recoverable";
-#endif
+# endif
 
-#if GNULIB_defined_EILSEQ
+# if GNULIB_defined_EILSEQ
     case EILSEQ:
       return "Invalid or incomplete multibyte or wide character";
-#endif
+# endif
 
     default:
       return NULL;
     }
 }
+
+#endif
index 03e98e3a3f4fb4cf779b1fed734a78a9b14ba771..9cfc5ad9b38156a1f73d476fd8aaf80df49d9ad8 100644 (file)
@@ -51,6 +51,7 @@
 extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST;
 # else
 #  define strerror_override(ignored) NULL
+#  define GNULIB_defined_strerror_override_macro 1
 # endif
 
 #endif /* _GL_STRERROR_OVERRIDE_H */