Page 1 of 1

strerror_r use in _GNU_SOURCE

Posted: 2011-09-07T02:26:47-07:00
by Petr
Hi,

we propose following patch:

Code: Select all

===================================================================
--- magick/exception.c.orig
+++ magick/exception.c
@@ -457,7 +457,11 @@ MagickExport char *GetExceptionMessage(c
 
   *exception='\0';
 #if defined(MAGICKCORE_HAVE_STRERROR_R)
-  (void) strerror_r(error,exception,sizeof(exception));
+  #if !defined(_GNU_SOURCE)
+    (void) strerror_r(error,exception,sizeof(exception));
+  #else
+    (void) CopyMagickString(exception,strerror_r(error, exception, sizeof(exception)),sizeof(exception));
+  #endif
 #else
   (void) CopyMagickString(exception,strerror(error),sizeof(exception));
 #endif
See https://bugzilla.novell.com/show_bug.cgi?id=673303 for details.
Thanks

Re: strerror_r use in _GNU_SOURCE

Posted: 2011-09-07T05:10:54-07:00
by magick
We'll get the patch into the next point release of ImageMagick, 6.7.2-4. Thanks.

Re: strerror_r use in _GNU_SOURCE

Posted: 2011-10-13T06:53:36-07:00
by agapon
It seems that this patch (now included into the source tree) breaks platforms with POSIX-compliant flavor of strerror_r.
Correct me if I am mistaken but it seems that the configure script unconditionally defines _GNU_SOURCE in magick/magick-config.h even on platforms like FreeBSD where libc always provides strerror_r with int return type.

Re: strerror_r use in _GNU_SOURCE

Posted: 2011-10-13T08:32:45-07:00
by magick
The best solution is to check for which version of strerror_r() we should use with the configure script. We'll add a patch to ImageMagick 6.7.3-2 by sometime tomorrow. Thanks.

Re: strerror_r use in _GNU_SOURCE

Posted: 2011-10-13T08:57:58-07:00
by agapon
That was my idea too. I tried the following patch here, could you please review it and check that it doesn't break things on Linux?
All the auto* stuff has to be regenerated from configure.ac, of course. config/config.h.in needs to be updated too, I think.

Code: Select all

Index: configure.ac
===================================================================
--- configure.ac	(revision 5619)
+++ configure.ac	(working copy)
@@ -1050,6 +1050,7 @@
 AC_TYPE_SIGNAL
 AC_FUNC_STRTOD
 AC_FUNC_VPRINTF
+AC_FUNC_STRERROR_R
 
 #
 # Find math library
@@ -1059,7 +1060,7 @@
 LIBS="$MATH_LIBS $LIBS"
 AC_SUBST(MATH_LIBS)
 
-AC_CHECK_FUNCS([acosh asinh atanh atoll atexit cabs carg cimag creal clock ctime_r directio _exit execvp fchmod floor fork ftime ftruncate getc_unlocked getcwd getpid getexecname getdtablesize getpagesize getrlimit getrusage gettimeofday gmtime_r j0 j1 lltostr localtime_r lstat memmove memset mkstemp munmap nanosleep newlocale _NSGetExecutablePath pclose _pclose poll popen _popen posix_fadvise posix_fallocate posix_madvise posix_memalign posix_spawnp pow pread pwrite qsort_r raise rand_r readlink readdir_r realpath select seekdir setlocale sqrt setvbuf stat strchr strerror_r strrchr strcspn strdup strpbrk strspn strstr strtod strtod_l strtol strtoul symlink sysconf sigemptyset sigaction spawnvp strerror strlcat strlcpy strcasecmp strncasecmp telldir tempnam times ulltostr uselocale usleep utime vfprintf vfprintf_l vsprintf vsnprintf vsnprintf_l waitpid _wfopen _wstat])
+AC_CHECK_FUNCS([acosh asinh atanh atoll atexit cabs carg cimag creal clock ctime_r directio _exit execvp fchmod floor fork ftime ftruncate getc_unlocked getcwd getpid getexecname getdtablesize getpagesize getrlimit getrusage gettimeofday gmtime_r j0 j1 lltostr localtime_r lstat memmove memset mkstemp munmap nanosleep newlocale _NSGetExecutablePath pclose _pclose poll popen _popen posix_fadvise posix_fallocate posix_madvise posix_memalign posix_spawnp pow pread pwrite qsort_r raise rand_r readlink readdir_r realpath select seekdir setlocale sqrt setvbuf stat strchr strrchr strcspn strdup strpbrk strspn strstr strtod strtod_l strtol strtoul symlink sysconf sigemptyset sigaction spawnvp strerror strlcat strlcpy strcasecmp strncasecmp telldir tempnam times ulltostr uselocale usleep utime vfprintf vfprintf_l vsprintf vsnprintf vsnprintf_l waitpid _wfopen _wstat])
 
 #
 # Check for clock_gettime().
Index: MagickCore/exception.c
===================================================================
--- MagickCore/exception.c	(revision 5619)
+++ MagickCore/exception.c	(working copy)
@@ -458,7 +458,7 @@
 
   *exception='\0';
 #if defined(MAGICKCORE_HAVE_STRERROR_R)
-#if !defined(_GNU_SOURCE)
+#if !defined(MAGICKCORE_STRERROR_R_CHAR_P)
   (void) strerror_r(error,exception,sizeof(exception));
 #else
   (void) CopyMagickString(exception,strerror_r(error,exception,