All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>
Cc: "David Hildenbrand" <david@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Drew Jones" <drjones@redhat.com>
Subject: [kvm-unit-tests v3 PATCH 2/3] Replace -Wextra with a saner list of warning flags
Date: Fri, 30 Jun 2017 12:00:18 +0200	[thread overview]
Message-ID: <1498816819-32666-3-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1498816819-32666-1-git-send-email-thuth@redhat.com>

Using -Wextra together with -Werror is troublesome - various versions
of GCC produce suspicious or even wrong warnings with -Wextra which
then become fatal errors with -Werror. For example, the current state
of the kvm-unit-tests does not compile anymore with GCC 4.8.1 for
s390x due to an inadequate -Wmissing-field-initializers warning.
That's annoying for users who just would like to compile the
kvm-unit-tests and cumbersome for the developers who have to work
around these problems in the source code. So let's replace -Wextra
by a saner lists of warning flags that are normally enabled by -Wextra.
Since they apparently can be used for building x86, too, the flags
are now also applied to the global CFLAGS instead of specifying them
for the single targets only.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 Makefile                | 8 ++++++--
 arm/Makefile.common     | 1 -
 powerpc/Makefile.common | 1 -
 s390x/Makefile          | 1 -
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 3ef6ea7..97d6591 100644
--- a/Makefile
+++ b/Makefile
@@ -50,8 +50,10 @@ include $(SRCDIR)/$(TEST_DIR)/Makefile
 cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
               > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
 
-COMMON_CFLAGS += -g
-COMMON_CFLAGS += $(autodepend-flags) -Wall -Wwrite-strings -Werror
+COMMON_CFLAGS += -g $(autodepend-flags)
+COMMON_CFLAGS += -Wall -Wwrite-strings -Wclobbered -Wempty-body -Wuninitialized
+COMMON_CFLAGS += -Wtype-limits -Wignored-qualifiers -Wunused-but-set-parameter
+COMMON_CFLAGS += -Werror
 frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer
 fomit_frame_pointer := $(call cc-option, $(frame-pointer-flag), "")
 fnostack_protector := $(call cc-option, -fno-stack-protector, "")
@@ -67,6 +69,8 @@ COMMON_CFLAGS += $(if $(U32_LONG_FMT),-D__U32_LONG_FMT__,)
 COMMON_CFLAGS += $(fno_pic) $(no_pie)
 
 CFLAGS += $(COMMON_CFLAGS)
+CFLAGS += -Wmissing-parameter-type -Wold-style-declaration -Woverride-init
+
 CXXFLAGS += $(COMMON_CFLAGS)
 
 autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
diff --git a/arm/Makefile.common b/arm/Makefile.common
index 03b497b..7e5f527 100644
--- a/arm/Makefile.common
+++ b/arm/Makefile.common
@@ -24,7 +24,6 @@ phys_base = $(LOADADDR)
 
 CFLAGS += -std=gnu99
 CFLAGS += -ffreestanding
-CFLAGS += -Wextra
 CFLAGS += -O2
 CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib
 
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index db5ba62..c4df2e9 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -19,7 +19,6 @@ all: directories $(TEST_DIR)/boot_rom.bin $(tests-all)
 
 CFLAGS += -std=gnu99
 CFLAGS += -ffreestanding
-CFLAGS += -Wextra
 CFLAGS += -O2
 CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib
 CFLAGS += -Wa,-mregnames
diff --git a/s390x/Makefile b/s390x/Makefile
index 470cbba..bc099da 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -7,7 +7,6 @@ test_cases: $(tests)
 
 CFLAGS += -std=gnu99
 CFLAGS += -ffreestanding
-CFLAGS += -Wextra
 CFLAGS += -I $(SRCDIR)/lib
 CFLAGS += -O2
 CFLAGS += -march=z900
-- 
1.8.3.1

  parent reply	other threads:[~2017-06-30 10:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30 10:00 [kvm-unit-tests v3 PATCH 0/3] Some more improvements related to compiler warnings Thomas Huth
2017-06-30 10:00 ` [kvm-unit-tests v3 PATCH 1/3] Move flags that are shared between C and C++ into COMMON_CFLAGS Thomas Huth
2017-06-30 10:00 ` Thomas Huth [this message]
2017-06-30 10:00 ` [kvm-unit-tests v3 PATCH 3/3] Mark some local functions as "static" Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498816819-32666-3-git-send-email-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=david@redhat.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.