From b3cf5084f2f7592c6f2821f55f9bf55ea223f569 Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Thu, 10 Sep 2015 09:46:15 +0100 Subject: [PATCH] Check we're building with GLIBC before assuming the GNU version of strerror_r is present Closes #1222 --- src/lib/log.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/log.c b/src/lib/log.c index 8f55061..49b3103 100644 --- a/src/lib/log.c +++ b/src/lib/log.c @@ -169,8 +169,8 @@ char const *fr_syserror(int num) /* * XSI-Compliant version */ -#if !defined(HAVE_FEATURES_H) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 500) && ! _GNU_SOURCE) - if ((ret = strerror_r(num, buffer, (size_t) FR_STRERROR_BUFSIZE) != 0)) { +#if !defined(HAVE_FEATURES_H) || !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 500) && ! _GNU_SOURCE) + if ((ret = strerror_r(num, buffer, (size_t)FR_STRERROR_BUFSIZE) != 0)) { # ifndef NDEBUG fprintf(stderr, "strerror_r() failed to write error for errno %i to buffer %p (%zu bytes), " "returned %i: %s\n", num, buffer, (size_t) FR_STRERROR_BUFSIZE, ret, strerror(ret)); @@ -187,7 +187,7 @@ char const *fr_syserror(int num) #else { char const *p; - p = strerror_r(num, buffer, (size_t) FR_STRERROR_BUFSIZE); + p = strerror_r(num, buffer, (size_t)FR_STRERROR_BUFSIZE); if (!p) { # ifndef NDEBUG fprintf(stderr, "strerror_r() failed to write error for errno %i to buffer %p "