]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Explain <isc/strerr.h> a little more
authorTony Finch <fanf@isc.org>
Fri, 16 Dec 2022 13:30:39 +0000 (13:30 +0000)
committerTony Finch <fanf@isc.org>
Wed, 15 Feb 2023 16:44:09 +0000 (16:44 +0000)
The purpose of the `strerror_r()` wrapper was not obvious.

CHANGES
lib/isc/include/isc/strerr.h
lib/isc/string.c

diff --git a/CHANGES b/CHANGES
index 270f9c7cb08ccdce9d868bdd8481ec5f1bc70989..63ec91928f1abe2c1e879e49cc40156becf5c039 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+6101.  [port]          Clarify the portability dodge needed for `strerror_r()`
+                       [GL !7465]
+
 6100.  [cleanup]       Deprecate <isc/deprecated.h>, because obsolete
                        functions are now deleted instead of marked with
                        an attribute. [GL !7466]
index 563ff48283e1fe114af8eb9ebb478ebb92552bd3..61f1c526a6dd4ecbdc8920d07cd226cc972ad9f3 100644 (file)
@@ -26,4 +26,8 @@
 #if defined(strerror_r)
 #undef strerror_r
 #endif /* if defined(strerror_r) */
+
+/*
+ * Ensure we use a consistent implementation of strerror_r()
+ */
 #define strerror_r isc_string_strerror_r
index 09cf5d636c1248891aa3ae2f718a198384936d63..7603ac2b25e0c22ee52c6b3f82adb8c77681f1d9 100644 (file)
 
 #include <isc/string.h> /* IWYU pragma: keep */
 
+/*
+ * We undef _GNU_SOURCE above to get the POSIX strerror_r()
+ */
+int
+isc_string_strerror_r(int errnum, char *buf, size_t buflen) {
+       return (strerror_r(errnum, buf, buflen));
+}
+
 #if !defined(HAVE_STRLCPY)
 size_t
 strlcpy(char *dst, const char *src, size_t size) {
@@ -136,8 +144,3 @@ strnstr(const char *s, const char *find, size_t slen) {
        return ((char *)s);
 }
 #endif
-
-int
-isc_string_strerror_r(int errnum, char *buf, size_t buflen) {
-       return (strerror_r(errnum, buf, buflen));
-}