diff mbox

Reenable -Wstrict-prototypes

Message ID 1361563731-13307-1-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf Feb. 22, 2013, 8:08 p.m. UTC
One part of this patch reverts commit 22bc9a46, which disabled the
warning. The rest of it deals with the warning by adding a #pragma for
newer gcc and by disabling -Werror for compilers that can't deal with
the #pragma.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 configure | 19 +++++++++++++------
 ui/gtk.c  | 12 +++++++++++-
 2 files changed, 24 insertions(+), 7 deletions(-)

Comments

Stefan Weil Feb. 22, 2013, 8:33 p.m. UTC | #1
Am 22.02.2013 21:08, schrieb Kevin Wolf:
> One part of this patch reverts commit 22bc9a46, which disabled the
> warning. The rest of it deals with the warning by adding a #pragma for
> newer gcc and by disabling -Werror for compilers that can't deal with
> the #pragma.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>


Would you mind using a different solution which needs less changes
and is more portable?

It's possible to have -Wstrict-prototypes in configure and
-Wno-strict-prototypes in ui/Makefile (only for ui/gtk.c).

I have this in my tree and can send a patch.

Regards,

Stefan W.
Kevin Wolf Feb. 22, 2013, 8:55 p.m. UTC | #2
Am 22.02.2013 um 21:33 hat Stefan Weil geschrieben:
> Am 22.02.2013 21:08, schrieb Kevin Wolf:
> > One part of this patch reverts commit 22bc9a46, which disabled the
> > warning. The rest of it deals with the warning by adding a #pragma for
> > newer gcc and by disabling -Werror for compilers that can't deal with
> > the #pragma.
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> 
> Would you mind using a different solution which needs less changes
> and is more portable?

Even less changes? This patch does already almost nothing, the biggest
change is the comment in configure...

Portability to which compiler is your concern exactly? I can't see what
this would break in practice.

> It's possible to have -Wstrict-prototypes in configure and
> -Wno-strict-prototypes in ui/Makefile (only for ui/gtk.c).

But ideally we'd disable it only for the header, not for ui/gtk.c as a
whole.

Kevin
Anthony Liguori Feb. 26, 2013, 7:20 p.m. UTC | #3
Applied.  Thanks.

Regards,

Anthony Liguori
diff mbox

Patch

diff --git a/configure b/configure
index 0dadd31..8817098 100755
--- a/configure
+++ b/configure
@@ -284,7 +284,7 @@  sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
 # default flags for all hosts
 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
-QEMU_CFLAGS="-Wredundant-decls $QEMU_CFLAGS"
+QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
 if test "$debug_info" = "yes"; then
@@ -3115,20 +3115,27 @@  if compile_prog "" "" ; then
 fi
 
 ########################################
-# check whether we can disable the -Wunused-but-set-variable
-# option with a pragma (this is needed to silence a warning in
-# some versions of the valgrind VALGRIND_STACK_DEREGISTER macro.)
-# This test has to be compiled with -Werror as otherwise an
-# unknown pragma is only a warning.
+# check whether we can disable warning option with a pragma (this is needed
+# to silence warnings in the headers of some versions of external libraries).
+# This test has to be compiled with -Werror as otherwise an unknown pragma is
+# only a warning.
+#
+# If we can't selectively disable warning in the code, disable -Werror so that
+# the build doesn't fail anyway.
+
 pragma_disable_unused_but_set=no
 cat > $TMPC << EOF
 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wstrict-prototypes"
+
 int main(void) {
     return 0;
 }
 EOF
 if compile_prog "-Werror" "" ; then
     pragma_diagnostic_available=yes
+else
+    werror=no
 fi
 
 ########################################
diff --git a/ui/gtk.c b/ui/gtk.c
index 29156be..0d36e8a 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -34,7 +34,18 @@ 
 #define GETTEXT_PACKAGE "qemu"
 #define LOCALEDIR "po"
 
+#include "qemu-common.h"
+
+#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
+/* Work around an -Wstrict-prototypes warning in GTK headers */
+#pragma GCC diagnostic ignored "-Wstrict-prototypes"
+#endif
 #include <gtk/gtk.h>
+#ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
+#pragma GCC diagnostic error "-Wstrict-prototypes"
+#endif
+
+
 #include <gdk/gdkkeysyms.h>
 #include <glib/gi18n.h>
 #include <vte/vte.h>
@@ -45,7 +56,6 @@ 
 #include <pty.h>
 #include <math.h>
 
-#include "qemu-common.h"
 #include "ui/console.h"
 #include "sysemu/sysemu.h"
 #include "qmp-commands.h"