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
This commit is contained in:
Igor Pashev 2017-06-20 13:38:00 +00:00 committed by Philip Withnall
parent bb50b70713
commit c8e268bbce
2 changed files with 4 additions and 3 deletions

View File

@ -525,7 +525,8 @@ AM_CONDITIONAL(OS_WIN32_AND_DLL_COMPILATION, [test x$glib_native_win32 = xyes -a
# Checks for library functions. # Checks for library functions.
AC_FUNC_ALLOCA AC_FUNC_ALLOCA
AC_CHECK_FUNCS(mmap posix_memalign memalign valloc fsync pipe2 issetugid) 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_CACHE_CHECK([for __libc_enable_secure], glib_cv_have_libc_enable_secure,
[AC_TRY_LINK([#include <unistd.h> [AC_TRY_LINK([#include <unistd.h>

View File

@ -1277,10 +1277,10 @@ g_strerror (gint errnum)
msg = buf; msg = buf;
#elif defined(HAVE_STRERROR_R) #elif defined(HAVE_STRERROR_R)
/* Match the condition in strerror_r(3) for glibc */ /* 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)); msg = strerror_r (errnum, buf, sizeof (buf));
# else # else
strerror_r (errnum, buf, sizeof (buf)); (void) strerror_r (errnum, buf, sizeof (buf));
msg = buf; msg = buf;
# endif /* HAVE_STRERROR_R */ # endif /* HAVE_STRERROR_R */
#else #else