All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH 0/3] Some more improvements related to compiler warnings
@ 2017-06-29 18:42 Thomas Huth
  2017-06-29 18:42 ` [kvm-unit-tests PATCH 1/3] Move flags that are shared between C and C++ into COMMON_CFLAGS Thomas Huth
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Thomas Huth @ 2017-06-29 18:42 UTC (permalink / raw)
  To: kvm, Paolo Bonzini
  Cc: David Hildenbrand, Radim Krčmář,
	Laurent Vivier, Drew Jones

Two patches to get rid of -Wextra and use other warning flags
globally instead, and an additional third patch to make some
functions "static" (to be able to compile the files with the
"-Wmissing-prototypes" parameter)

Thomas Huth (3):
  Move flags that are shared between C and C++ into COMMON_CFLAGS
  Replace -Wextra with a saner list of warning flags
  Mark some local functions as "static"

 Makefile                | 27 ++++++++++++++++-----------
 arm/Makefile.common     |  1 -
 arm/pmu.c               |  2 +-
 lib/pci-testdev.c       |  4 ++--
 lib/printf.c            |  8 ++++----
 lib/x86/fwcfg.c         |  2 +-
 powerpc/Makefile.common |  1 -
 s390x/Makefile          |  1 -
 s390x/intercept.c       |  2 +-
 x86/Makefile.common     |  4 ++--
 x86/Makefile.x86_64     |  2 +-
 11 files changed, 28 insertions(+), 26 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [kvm-unit-tests PATCH 1/3] Move flags that are shared between C and C++ into COMMON_CFLAGS
  2017-06-29 18:42 [kvm-unit-tests PATCH 0/3] Some more improvements related to compiler warnings Thomas Huth
@ 2017-06-29 18:42 ` Thomas Huth
  2017-06-29 18:42 ` [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags Thomas Huth
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2017-06-29 18:42 UTC (permalink / raw)
  To: kvm, Paolo Bonzini
  Cc: David Hildenbrand, Radim Krčmář,
	Laurent Vivier, Drew Jones

This way we can add some C-only parameters to CFLAGS later.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 Makefile            | 21 +++++++++++----------
 x86/Makefile.common |  4 ++--
 x86/Makefile.x86_64 |  2 +-
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index e79cf93..3ef6ea7 100644
--- a/Makefile
+++ b/Makefile
@@ -50,8 +50,8 @@ 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 ;)
 
-CFLAGS += -g
-CFLAGS += $(autodepend-flags) -Wall -Wwrite-strings -Werror
+COMMON_CFLAGS += -g
+COMMON_CFLAGS += $(autodepend-flags) -Wall -Wwrite-strings -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, "")
@@ -59,14 +59,15 @@ fnostack_protector_all := $(call cc-option, -fno-stack-protector-all, "")
 wno_frame_address := $(call cc-option, -Wno-frame-address, "")
 fno_pic := $(call cc-option, -fno-pic, "")
 no_pie := $(call cc-option, -no-pie, "")
-CFLAGS += $(fomit_frame_pointer)
-CFLAGS += $(fno_stack_protector)
-CFLAGS += $(fno_stack_protector_all)
-CFLAGS += $(wno_frame_address)
-CFLAGS += $(if $(U32_LONG_FMT),-D__U32_LONG_FMT__,)
-CFLAGS += $(fno_pic) $(no_pie)
-
-CXXFLAGS += $(CFLAGS)
+COMMON_CFLAGS += $(fomit_frame_pointer)
+COMMON_CFLAGS += $(fno_stack_protector)
+COMMON_CFLAGS += $(fno_stack_protector_all)
+COMMON_CFLAGS += $(wno_frame_address)
+COMMON_CFLAGS += $(if $(U32_LONG_FMT),-D__U32_LONG_FMT__,)
+COMMON_CFLAGS += $(fno_pic) $(no_pie)
+
+CFLAGS += $(COMMON_CFLAGS)
+CXXFLAGS += $(COMMON_CFLAGS)
 
 autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
 
diff --git a/x86/Makefile.common b/x86/Makefile.common
index ca97a8e..e96812b 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -21,8 +21,8 @@ OBJDIRS += lib/x86
 $(libcflat): LDFLAGS += -nostdlib
 $(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
 
-CFLAGS += -m$(bits)
-CFLAGS += -O1
+COMMON_CFLAGS += -m$(bits)
+COMMON_CFLAGS += -O1
 
 # stack.o relies on frame pointers.
 KEEP_FRAME_POINTER := y
diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64
index fd34cce..623fc5b 100644
--- a/x86/Makefile.x86_64
+++ b/x86/Makefile.x86_64
@@ -1,7 +1,7 @@
 cstart.o = $(TEST_DIR)/cstart64.o
 bits = 64
 ldarch = elf64-x86-64
-CFLAGS += -mno-red-zone
+COMMON_CFLAGS += -mno-red-zone
 
 cflatobjs += lib/x86/setjmp64.o
 cflatobjs += lib/x86/intel-iommu.o
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags
  2017-06-29 18:42 [kvm-unit-tests PATCH 0/3] Some more improvements related to compiler warnings Thomas Huth
  2017-06-29 18:42 ` [kvm-unit-tests PATCH 1/3] Move flags that are shared between C and C++ into COMMON_CFLAGS Thomas Huth
@ 2017-06-29 18:42 ` Thomas Huth
  2017-06-30  8:07   ` Andrew Jones
                     ` (2 more replies)
  2017-06-29 18:42 ` [kvm-unit-tests PATCH 3/3] Mark some local functions as "static" Thomas Huth
  2017-06-30 10:08 ` [kvm-unit-tests PATCH 0/3] Some more improvements related to compiler warnings Paolo Bonzini
  3 siblings, 3 replies; 11+ messages in thread
From: Thomas Huth @ 2017-06-29 18:42 UTC (permalink / raw)
  To: kvm, Paolo Bonzini
  Cc: David Hildenbrand, Radim Krčmář,
	Laurent Vivier, Drew Jones

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>
---
 v2:
 - Now that we've got COMMON_CFLAGS, the remaining flags can be
   added to the global CFLAGS, too
 - Removed -Wsign-compare

 Makefile                | 10 +++++++---
 arm/Makefile.common     |  1 -
 powerpc/Makefile.common |  1 -
 s390x/Makefile          |  1 -
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 3ef6ea7..f12b2df 100644
--- a/Makefile
+++ b/Makefile
@@ -50,9 +50,11 @@ 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
-frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer
+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
+ rame-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, "")
 fnostack_protector_all := $(call cc-option, -fno-stack-protector-all, "")
@@ -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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [kvm-unit-tests PATCH 3/3] Mark some local functions as "static"
  2017-06-29 18:42 [kvm-unit-tests PATCH 0/3] Some more improvements related to compiler warnings Thomas Huth
  2017-06-29 18:42 ` [kvm-unit-tests PATCH 1/3] Move flags that are shared between C and C++ into COMMON_CFLAGS Thomas Huth
  2017-06-29 18:42 ` [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags Thomas Huth
@ 2017-06-29 18:42 ` Thomas Huth
  2017-06-30 10:07   ` Paolo Bonzini
  2017-06-30 10:08 ` [kvm-unit-tests PATCH 0/3] Some more improvements related to compiler warnings Paolo Bonzini
  3 siblings, 1 reply; 11+ messages in thread
From: Thomas Huth @ 2017-06-29 18:42 UTC (permalink / raw)
  To: kvm, Paolo Bonzini
  Cc: David Hildenbrand, Radim Krčmář,
	Laurent Vivier, Drew Jones

Discovered while compiling kvm-unit-tests with the
"-Wmissing-prototypes" parameter of GCC.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 NB: There's more to do to make the whole code compilable with
 "-Wmissing-prototypes" ... not sure whether we really want all
 that, but at least these spots in this patch here seemed to make
 sense to me.

 arm/pmu.c         | 2 +-
 lib/pci-testdev.c | 4 ++--
 lib/printf.c      | 8 ++++----
 lib/x86/fwcfg.c   | 2 +-
 s390x/intercept.c | 2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arm/pmu.c b/arm/pmu.c
index 1ac6920..1de7d77 100644
--- a/arm/pmu.c
+++ b/arm/pmu.c
@@ -276,7 +276,7 @@ static void pmccntr64_test(void)
 }
 
 /* Return FALSE if no PMU found, otherwise return TRUE */
-bool pmu_probe(void)
+static bool pmu_probe(void)
 {
 	pmu_version = get_pmu_version();
 	report_info("PMU version: %d", pmu_version);
diff --git a/lib/pci-testdev.c b/lib/pci-testdev.c
index 7d298e6..039bb44 100644
--- a/lib/pci-testdev.c
+++ b/lib/pci-testdev.c
@@ -131,8 +131,8 @@ static bool pci_testdev_one(struct pci_test_dev_hdr *test,
 	return (int)count == nr_writes;
 }
 
-void pci_testdev_print(struct pci_test_dev_hdr *test,
-		       struct pci_testdev_ops *ops)
+static void pci_testdev_print(struct pci_test_dev_hdr *test,
+			      struct pci_testdev_ops *ops)
 {
 	bool io = (ops == &pci_testdev_io_ops);
 	int i;
diff --git a/lib/printf.c b/lib/printf.c
index bfe05f5..1269723 100644
--- a/lib/printf.c
+++ b/lib/printf.c
@@ -30,7 +30,7 @@ static void addchar(pstream_t *p, char c)
     ++p->added;
 }
 
-void print_str(pstream_t *p, const char *s, strprops_t props)
+static void print_str(pstream_t *p, const char *s, strprops_t props)
 {
     const char *s_orig = s;
     int npad = props.npad;
@@ -58,7 +58,7 @@ void print_str(pstream_t *p, const char *s, strprops_t props)
 
 static char digits[16] = "0123456789abcdef";
 
-void print_int(pstream_t *ps, long long n, int base, strprops_t props)
+static void print_int(pstream_t *ps, long long n, int base, strprops_t props)
 {
     char buf[sizeof(long) * 3 + 2], *p = buf;
     int s = 0, i;
@@ -92,8 +92,8 @@ void print_int(pstream_t *ps, long long n, int base, strprops_t props)
     print_str(ps, buf, props);
 }
 
-void print_unsigned(pstream_t *ps, unsigned long long n, int base,
-		    strprops_t props)
+static void print_unsigned(pstream_t *ps, unsigned long long n, int base,
+			   strprops_t props)
 {
     char buf[sizeof(long) * 3 + 3], *p = buf;
     int i;
diff --git a/lib/x86/fwcfg.c b/lib/x86/fwcfg.c
index e2cdd15..c52b445 100644
--- a/lib/x86/fwcfg.c
+++ b/lib/x86/fwcfg.c
@@ -3,7 +3,7 @@
 
 static struct spinlock lock;
 
-uint64_t fwcfg_get_u(uint16_t index, int bytes)
+static uint64_t fwcfg_get_u(uint16_t index, int bytes)
 {
     uint64_t r = 0;
     uint8_t b;
diff --git a/s390x/intercept.c b/s390x/intercept.c
index 9766289..59e5fca 100644
--- a/s390x/intercept.c
+++ b/s390x/intercept.c
@@ -182,7 +182,7 @@ struct {
 	{ NULL, NULL, false }
 };
 
-void parse_intercept_test_args(int argc, char **argv)
+static void parse_intercept_test_args(int argc, char **argv)
 {
 	int i, ti;
 	bool run_all = true;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags
  2017-06-29 18:42 ` [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags Thomas Huth
@ 2017-06-30  8:07   ` Andrew Jones
  2017-06-30  9:08     ` Thomas Huth
  2017-06-30  8:19   ` Andrew Jones
  2017-06-30 10:06   ` Paolo Bonzini
  2 siblings, 1 reply; 11+ messages in thread
From: Andrew Jones @ 2017-06-30  8:07 UTC (permalink / raw)
  To: Thomas Huth
  Cc: kvm, Paolo Bonzini, David Hildenbrand,
	Radim Krčmář,
	Laurent Vivier

On Thu, Jun 29, 2017 at 08:42:52PM +0200, Thomas Huth wrote:
> 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>
> ---
>  v2:
>  - Now that we've got COMMON_CFLAGS, the remaining flags can be
>    added to the global CFLAGS, too
>  - Removed -Wsign-compare
> 
>  Makefile                | 10 +++++++---
>  arm/Makefile.common     |  1 -
>  powerpc/Makefile.common |  1 -
>  s390x/Makefile          |  1 -
>  4 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 3ef6ea7..f12b2df 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -50,9 +50,11 @@ 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
> -frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer
> +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
> + rame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer

Some finger fumbling here.

>  fomit_frame_pointer := $(call cc-option, $(frame-pointer-flag), "")
>  fnostack_protector := $(call cc-option, -fno-stack-protector, "")
>  fnostack_protector_all := $(call cc-option, -fno-stack-protector-all, "")
> @@ -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
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags
  2017-06-29 18:42 ` [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags Thomas Huth
  2017-06-30  8:07   ` Andrew Jones
@ 2017-06-30  8:19   ` Andrew Jones
  2017-06-30  9:09     ` Thomas Huth
  2017-06-30 10:06   ` Paolo Bonzini
  2 siblings, 1 reply; 11+ messages in thread
From: Andrew Jones @ 2017-06-30  8:19 UTC (permalink / raw)
  To: Thomas Huth
  Cc: kvm, Paolo Bonzini, David Hildenbrand,
	Radim Krčmář,
	Laurent Vivier

On Thu, Jun 29, 2017 at 08:42:52PM +0200, Thomas Huth wrote:
> 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>
> ---
>  v2:
>  - Now that we've got COMMON_CFLAGS, the remaining flags can be
>    added to the global CFLAGS, too
>  - Removed -Wsign-compare

I was just doing some reading about warning types. It looks like
-Wsign-compare comes with -Wall anyway.

drew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags
  2017-06-30  8:07   ` Andrew Jones
@ 2017-06-30  9:08     ` Thomas Huth
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2017-06-30  9:08 UTC (permalink / raw)
  To: Andrew Jones
  Cc: kvm, Paolo Bonzini, David Hildenbrand,
	Radim Krčmář,
	Laurent Vivier

On 30.06.2017 10:07, Andrew Jones wrote:
> On Thu, Jun 29, 2017 at 08:42:52PM +0200, Thomas Huth wrote:
>> 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>
>> ---
>>  v2:
>>  - Now that we've got COMMON_CFLAGS, the remaining flags can be
>>    added to the global CFLAGS, too
>>  - Removed -Wsign-compare
>>
>>  Makefile                | 10 +++++++---
>>  arm/Makefile.common     |  1 -
>>  powerpc/Makefile.common |  1 -
>>  s390x/Makefile          |  1 -
>>  4 files changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 3ef6ea7..f12b2df 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -50,9 +50,11 @@ 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
>> -frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer
>> +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
>> + rame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer
> 
> Some finger fumbling here.

Ooops, ... very well spotted ... I'll send a v3

 Thomas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags
  2017-06-30  8:19   ` Andrew Jones
@ 2017-06-30  9:09     ` Thomas Huth
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2017-06-30  9:09 UTC (permalink / raw)
  To: Andrew Jones
  Cc: kvm, Paolo Bonzini, David Hildenbrand,
	Radim Krčmář,
	Laurent Vivier

On 30.06.2017 10:19, Andrew Jones wrote:
> On Thu, Jun 29, 2017 at 08:42:52PM +0200, Thomas Huth wrote:
>> 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>
>> ---
>>  v2:
>>  - Now that we've got COMMON_CFLAGS, the remaining flags can be
>>    added to the global CFLAGS, too
>>  - Removed -Wsign-compare
> 
> I was just doing some reading about warning types. It looks like
> -Wsign-compare comes with -Wall anyway.

According to https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
it's only enabled by -Wall when you're compiling a C++ file, for plain C
it is only enabled by -Wextra.

 Thomas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags
  2017-06-29 18:42 ` [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags Thomas Huth
  2017-06-30  8:07   ` Andrew Jones
  2017-06-30  8:19   ` Andrew Jones
@ 2017-06-30 10:06   ` Paolo Bonzini
  2 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2017-06-30 10:06 UTC (permalink / raw)
  To: Thomas Huth, kvm
  Cc: David Hildenbrand, Radim Krčmář,
	Laurent Vivier, Drew Jones



On 29/06/2017 20:42, Thomas Huth wrote:
> + rame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer

Fixed the first character of this line.

Paolo

>  fomit_frame_pointer := $(call cc-option, $(frame-pointer-flag), "")
>  fnostack_protector := $(call cc-option, -fno-stack-protector, "")

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [kvm-unit-tests PATCH 3/3] Mark some local functions as "static"
  2017-06-29 18:42 ` [kvm-unit-tests PATCH 3/3] Mark some local functions as "static" Thomas Huth
@ 2017-06-30 10:07   ` Paolo Bonzini
  0 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2017-06-30 10:07 UTC (permalink / raw)
  To: Thomas Huth, kvm
  Cc: David Hildenbrand, Radim Krčmář,
	Laurent Vivier, Drew Jones



On 29/06/2017 20:42, Thomas Huth wrote:
> Discovered while compiling kvm-unit-tests with the
> "-Wmissing-prototypes" parameter of GCC.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  NB: There's more to do to make the whole code compilable with
>  "-Wmissing-prototypes" ... not sure whether we really want all
>  that, but at least these spots in this patch here seemed to make
>  sense to me.

Yes, I think we want that.

Paolo

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [kvm-unit-tests PATCH 0/3] Some more improvements related to compiler warnings
  2017-06-29 18:42 [kvm-unit-tests PATCH 0/3] Some more improvements related to compiler warnings Thomas Huth
                   ` (2 preceding siblings ...)
  2017-06-29 18:42 ` [kvm-unit-tests PATCH 3/3] Mark some local functions as "static" Thomas Huth
@ 2017-06-30 10:08 ` Paolo Bonzini
  3 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2017-06-30 10:08 UTC (permalink / raw)
  To: Thomas Huth, kvm
  Cc: David Hildenbrand, Radim Krčmář,
	Laurent Vivier, Drew Jones



On 29/06/2017 20:42, Thomas Huth wrote:
> Two patches to get rid of -Wextra and use other warning flags
> globally instead, and an additional third patch to make some
> functions "static" (to be able to compile the files with the
> "-Wmissing-prototypes" parameter)
> 
> Thomas Huth (3):
>   Move flags that are shared between C and C++ into COMMON_CFLAGS
>   Replace -Wextra with a saner list of warning flags
>   Mark some local functions as "static"
> 
>  Makefile                | 27 ++++++++++++++++-----------
>  arm/Makefile.common     |  1 -
>  arm/pmu.c               |  2 +-
>  lib/pci-testdev.c       |  4 ++--
>  lib/printf.c            |  8 ++++----
>  lib/x86/fwcfg.c         |  2 +-
>  powerpc/Makefile.common |  1 -
>  s390x/Makefile          |  1 -
>  s390x/intercept.c       |  2 +-
>  x86/Makefile.common     |  4 ++--
>  x86/Makefile.x86_64     |  2 +-
>  11 files changed, 28 insertions(+), 26 deletions(-)
> 

Applied, thanks.

Paolo

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-06-30 10:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 18:42 [kvm-unit-tests PATCH 0/3] Some more improvements related to compiler warnings Thomas Huth
2017-06-29 18:42 ` [kvm-unit-tests PATCH 1/3] Move flags that are shared between C and C++ into COMMON_CFLAGS Thomas Huth
2017-06-29 18:42 ` [kvm-unit-tests v2 PATCH 2/3] Replace -Wextra with a saner list of warning flags Thomas Huth
2017-06-30  8:07   ` Andrew Jones
2017-06-30  9:08     ` Thomas Huth
2017-06-30  8:19   ` Andrew Jones
2017-06-30  9:09     ` Thomas Huth
2017-06-30 10:06   ` Paolo Bonzini
2017-06-29 18:42 ` [kvm-unit-tests PATCH 3/3] Mark some local functions as "static" Thomas Huth
2017-06-30 10:07   ` Paolo Bonzini
2017-06-30 10:08 ` [kvm-unit-tests PATCH 0/3] Some more improvements related to compiler warnings Paolo Bonzini

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.