summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2021-06-29 02:17:30 +0200
committerBruno Haible <bruno@clisp.org>2021-06-29 02:19:32 +0200
commit83f83c91604e1272cb4fe0bf707081ca7a8905a5 (patch)
treecfcedfe165e6def4ebef23866dec82c191a99dc0
parent4005b659fa7c000249b7cb6a6bbc79ef5a4a4106 (diff)
downloadgnulib-83f83c91604e1272cb4fe0bf707081ca7a8905a5.tar.gz
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.
-rw-r--r--ChangeLog9
-rw-r--r--lib/strerror-override.c86
-rw-r--r--lib/strerror-override.h1
3 files changed, 55 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index ace8ade4c6..05f196a933 100644
--- 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.
diff --git a/lib/strerror-override.c b/lib/strerror-override.c
index 172a1d3d76..e76d55dbaf 100644
--- a/lib/strerror-override.c
+++ b/lib/strerror-override.c
@@ -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
diff --git a/lib/strerror-override.h b/lib/strerror-override.h
index 03e98e3a3f..9cfc5ad9b3 100644
--- a/lib/strerror-override.h
+++ b/lib/strerror-override.h
@@ -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 */