From b0893ae09a6eb74e0f7e06b3da515d735ed7b323 Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Fri, 16 Dec 2022 13:30:39 +0000 Subject: [PATCH] Explain a little more The purpose of the `strerror_r()` wrapper was not obvious. --- CHANGES | 3 +++ lib/isc/include/isc/strerr.h | 4 ++++ lib/isc/string.c | 13 ++++++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 270f9c7cb0..63ec91928f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +6101. [port] Clarify the portability dodge needed for `strerror_r()` + [GL !7465] + 6100. [cleanup] Deprecate , because obsolete functions are now deleted instead of marked with an attribute. [GL !7466] diff --git a/lib/isc/include/isc/strerr.h b/lib/isc/include/isc/strerr.h index 563ff48283..61f1c526a6 100644 --- a/lib/isc/include/isc/strerr.h +++ b/lib/isc/include/isc/strerr.h @@ -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 diff --git a/lib/isc/string.c b/lib/isc/string.c index 09cf5d636c..7603ac2b25 100644 --- a/lib/isc/string.c +++ b/lib/isc/string.c @@ -55,6 +55,14 @@ #include /* 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)); -}