[svn] gcry - r1352 - in trunk: . src

svn author wk cvs at cvs.gnupg.org
Thu Oct 30 12:56:58 CET 2008


Author: wk
Date: 2008-10-30 12:56:57 +0100 (Thu, 30 Oct 2008)
New Revision: 1352

Modified:
   trunk/ChangeLog
   trunk/autogen.sh
   trunk/configure.ac
   trunk/src/ChangeLog
   trunk/src/g10lib.h
Log:
Autodetect useful gcc warnings in maintainer-mode.
Flag _gcry_gettext with format_arg attribute.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-10-30 10:23:17 UTC (rev 1351)
+++ trunk/ChangeLog	2008-10-30 11:56:57 UTC (rev 1352)
@@ -1,3 +1,8 @@
+2008-10-30  Werner Koch  <wk at g10code.com>
+
+	* configure.ac: Remove option --enable-gcc-warnings.  Autodetect
+	useful gcc warnings in maintainer mode.
+
 2008-09-18  Werner Koch  <wk at g10code.com>
 
 	Release 1.4.3.

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2008-10-30 10:23:17 UTC (rev 1351)
+++ trunk/src/ChangeLog	2008-10-30 11:56:57 UTC (rev 1352)
@@ -1,3 +1,8 @@
+2008-10-30  Werner Koch  <wk at g10code.com>
+
+	* g10lib.h (GCC_ATTR_FORMAT_ARG): New.
+	(_gcry_gettext): Use it.
+
 2008-10-24  Werner Koch  <wk at g10code.com>
 
 	* global.c (inactive_fips_mode): Move to fips.c. 

Modified: trunk/autogen.sh
===================================================================
--- trunk/autogen.sh	2008-10-30 10:23:17 UTC (rev 1351)
+++ trunk/autogen.sh	2008-10-30 11:56:57 UTC (rev 1352)
@@ -195,5 +195,6 @@
 echo "Running autoconf${FORCE} ..."
 $AUTOCONF${FORCE}
 
-echo "You may now run \"./configure --enable-maintainer-mode && make\"."
-echo "(gcc users may want to add the option \"--enable-gcc-warnings\")"
+echo "You may now run: 
+  ./configure --enable-maintainer-mode && make
+"

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2008-10-30 10:23:17 UTC (rev 1351)
+++ trunk/configure.ac	2008-10-30 11:56:57 UTC (rev 1352)
@@ -852,39 +852,40 @@
                          CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
                        fi])
 
-AC_ARG_ENABLE(gcc-warnings,
-	      AC_HELP_STRING([--enable-gcc-warnings],
-			     [enable more verbose gcc warnings]),
-	      [more_gcc_warnings="$enableval"],
-	      [more_gcc_warnings="no"])
+# CFLAGS mangling when using gcc.
+if test "$GCC" = yes; then
+    CFLAGS="$CFLAGS -Wall"
+    if test "$USE_MAINTAINER_MODE" = "yes"; then
+        CFLAGS="$CFLAGS -Wcast-align -Wshadow -Wstrict-prototypes"
+        CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
 
-if test "$GCC" = yes; then
-    if test "$USE_MAINTAINER_MODE" = "yes" ||
-       test "$more_gcc_warnings" = "yes"; then
-        CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
-        if test "$more_gcc_warnings" = "yes"; then
-            CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
-            CFLAGS="$CFLAGS -Wwrite-strings"
-            CFLAGS="$CFLAGS -Wdeclaration-after-statement"
-            CFLAGS="$CFLAGS -Wno-missing-field-initializers"
-            CFLAGS="$CFLAGS -Wno-sign-compare"
-            # Note: We don't use -Wunreachable-code because this gives
-            # warnings for all asserts and many inline functions like
-            # gpg_error (gcc 4.1.2 20060928).
+        # If -Wno-missing-field-initializers is supported we can enable a 
+        # a bunch of really useful warnings.
+        AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
+        _gcc_cflags_save=$CFLAGS
+        CFLAGS="-Wno-missing-field-initializers"
+        AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no)
+        AC_MSG_RESULT($_gcc_wopt)
+        CFLAGS=$_gcc_cflags_save;
+        if test x"$_gcc_wopt" = xyes ; then
+          CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast"
+          CFLAGS="$CFLAGS -Wwrite-strings"
+          CFLAGS="$CFLAGS -Wdeclaration-after-statement"
+          CFLAGS="$CFLAGS -Wno-missing-field-initializers"
+          CFLAGS="$CFLAGS -Wno-sign-compare"
         fi
-    else
-        CFLAGS="$CFLAGS -Wall"
+
+        AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
+        _gcc_cflags_save=$CFLAGS
+        CFLAGS="-Wpointer-arith"
+        AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no)
+        AC_MSG_RESULT($_gcc_wopt)
+        CFLAGS=$_gcc_cflags_save;
+        if test x"$_gcc_wopt" = xyes ; then
+          CFLAGS="$CFLAGS -Wpointer-arith"
+        fi
     fi
 
-    AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
-    _gcc_cflags_save=$CFLAGS
-    CFLAGS="-Wpointer-arith"
-    AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no)
-    AC_MSG_RESULT($_gcc_wopt)
-    CFLAGS=$_gcc_cflags_save;
-    if test x"$_gcc_wopt" = xyes ; then
-       CFLAGS="$CFLAGS -Wpointer-arith"
-    fi
 fi
 
 # Check whether as(1) supports a noeexecstack feature.  This test

Modified: trunk/src/g10lib.h
===================================================================
--- trunk/src/g10lib.h	2008-10-30 10:23:17 UTC (rev 1351)
+++ trunk/src/g10lib.h	2008-10-30 11:56:57 UTC (rev 1352)
@@ -58,6 +58,15 @@
 #define GCC_ATTR_NORETURN 
 #endif
 
+#if __GNUC__ >= 3 
+/* According to glibc this attribute is available since 2.8 however we
+   better play safe and use it only with gcc 3 or newer. */
+#define GCC_ATTR_FORMAT_ARG(a)  __attribute__ ((format_arg (a)))
+#else
+#define GCC_ATTR_FORMAT_ARG(a)  
+#endif
+
+
 /* Gettext macros.  */
 
 #define _(a)  _gcry_gettext(a)
@@ -92,7 +101,7 @@
 void _gcry_assert_failed (const char *expr, const char *file, int line);
 #endif
 
-const char *_gcry_gettext (const char *key);
+const char *_gcry_gettext (const char *key) GCC_ATTR_FORMAT_ARG(1);
 void _gcry_fatal_error(int rc, const char *text ) JNLIB_GCC_A_NR;
 void _gcry_log( int level, const char *fmt, ... ) JNLIB_GCC_A_PRINTF(2,3);
 void _gcry_log_bug( const char *fmt, ... )   JNLIB_GCC_A_NR_PRINTF(1,2);




More information about the Gnupg-commits mailing list