[glib] Fix detection and usage of strerror_r()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Fix detection and usage of strerror_r()
- Date: Tue, 20 Jun 2017 14:24:55 +0000 (UTC)
commit c8e268bbce70ee05da5a94e424517168a14c7645
Author: Igor Pashev <pashev igor gmail com>
Date: Tue Jun 20 13:38:00 2017 +0000
Fix detection and usage of strerror_r()
autoconf provides a macro for this situation, which saves us having to
manually work out whether strerror_r() returns a char* or an int.
https://bugzilla.gnome.org/show_bug.cgi?id=784000
configure.ac | 3 ++-
glib/gstrfuncs.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c653a92..00042e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -525,7 +525,8 @@ AM_CONDITIONAL(OS_WIN32_AND_DLL_COMPILATION, [test x$glib_native_win32 = xyes -a
# Checks for library functions.
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(mmap posix_memalign memalign valloc fsync pipe2 issetugid)
-AC_CHECK_FUNCS(timegm gmtime_r strerror_r)
+AC_CHECK_FUNCS(timegm gmtime_r)
+AC_FUNC_STRERROR_R()
AC_CACHE_CHECK([for __libc_enable_secure], glib_cv_have_libc_enable_secure,
[AC_TRY_LINK([#include <unistd.h>
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index fcf4927..cf89bf5 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -1277,10 +1277,10 @@ g_strerror (gint errnum)
msg = buf;
#elif defined(HAVE_STRERROR_R)
/* Match the condition in strerror_r(3) for glibc */
-# if defined(__GLIBC__) && !((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)
+# if defined(STRERROR_R_CHAR_P)
msg = strerror_r (errnum, buf, sizeof (buf));
# else
- strerror_r (errnum, buf, sizeof (buf));
+ (void) strerror_r (errnum, buf, sizeof (buf));
msg = buf;
# endif /* HAVE_STRERROR_R */
#else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]