[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] PATCH: Fix compiler flag check for -Wformat-security



Certain versions of GCC will ignore the -Wformat-security flag unless you
have also set the -Wformat flag. Unfortunately when checking flags, we only
check one at a time in isolation, so it was thinking -Wformat-security
is not supported in Fedora. The fix is to include all previously verified
flags during the check process, but not for -Werror because for added fun,
the autoconf test program itself causes compile warnings with some flags
we have. The patch also fixes 3 harmless format problems in virsh

Daniel

Index: m4/compiler-flags.m4
===================================================================
RCS file: /data/cvs/libvirt/m4/compiler-flags.m4,v
retrieving revision 1.2
diff -u -p -r1.2 compiler-flags.m4
--- m4/compiler-flags.m4	14 Jan 2009 15:23:26 -0000	1.2
+++ m4/compiler-flags.m4	27 Apr 2009 10:34:43 -0000
@@ -24,7 +24,15 @@ AC_DEFUN([gl_COMPILER_FLAGS],
   [AC_MSG_CHECKING(whether compiler accepts $1)
    AC_SUBST(COMPILER_FLAGS)
    ac_save_CFLAGS="$CFLAGS"
-   CFLAGS="$CFLAGS $1"
+   dnl Some flags are dependant, so we set all previously checked
+   dnl flags when testing. Except for -Werror which we have to 
+   dnl check on its own, because some of our compiler flags cause
+   dnl warnings from the autoconf test program!
+   if test "$1" = "-Werror" ; then
+     CFLAGS="$CFLAGS $1"
+   else
+     CFLAGS="$CFLAGS $COMPILER_FLAGS $1"
+   fi
    AC_TRY_LINK([], [], has_option=yes, has_option=no,)
    echo 'int x;' >conftest.c
    $CC $CFLAGS -c conftest.c 2>conftest.err
Index: src/virsh.c
===================================================================
RCS file: /data/cvs/libvirt/src/virsh.c,v
retrieving revision 1.201
diff -u -p -r1.201 virsh.c
--- src/virsh.c	15 Apr 2009 20:09:09 -0000	1.201
+++ src/virsh.c	27 Apr 2009 10:34:45 -0000
@@ -4463,7 +4463,7 @@ cmdNodeListDevicesPrint(vshControl *ctl,
     }
 
     /* Print this device */
-    vshPrint(ctl, indentBuf);
+    vshPrint(ctl, "%s", indentBuf);
     vshPrint(ctl, "%s\n", devices[devid]);
 
 
@@ -4487,7 +4487,7 @@ cmdNodeListDevicesPrint(vshControl *ctl,
 
     /* If there is a child device, then print another blank line */
     if (nextlastdev != -1) {
-        vshPrint(ctl, indentBuf);
+        vshPrint(ctl, "%s", indentBuf);
         vshPrint(ctl, "  |\n");
     }
 
@@ -4511,7 +4511,7 @@ cmdNodeListDevicesPrint(vshControl *ctl,
     /* If there was no child device, and we're the last in
      * a list of devices, then print another blank line */
     if (nextlastdev == -1 && devid == lastdev) {
-        vshPrint(ctl, indentBuf);
+        vshPrint(ctl, "%s", indentBuf);
         vshPrint(ctl, "\n");
     }
 }


-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]