]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: build with -Wextra and sort out certain warnings
authorWilly Tarreau <w@1wt.eu>
Thu, 20 Sep 2018 08:38:08 +0000 (10:38 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Sep 2018 09:43:19 +0000 (11:43 +0200)
We're not far from being able to build with -Wextra -Werror. The
following warnings had to be disabled to enable a clean build at
-Wextra on x86_64 using gcc 4.7, 5.5, 6.4 and 7.3 :

   sign-compare, unused-parameter, old-style-declaration,
   ignored-qualifiers, clobbered, missing-field-initializers,
   implicit-fallthrough

The following extra warnings could be added without side effects :

   type-limits, shift-negative-value, shift-overflow=2 duplicated-cond,
   null-dereference

As a result, -Wextra was enabled by default, hoping it will help catch
issues over the long term. If new undesired warnings pop up, it's easy
to disable them using the nowarn call.

Makefile

index 4b5cc40720147e1f6143e7883ce6792312ac67cd..382f944f3d828cc246d93f0289e55f956bcd786e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -153,8 +153,19 @@ SPEC_CFLAGS += $(call cc-opt,-fwrapv)
 SPEC_CFLAGS += $(call cc-opt,-fno-strict-overflow)
 SPEC_CFLAGS += $(call cc-nowarn,format-truncation)
 SPEC_CFLAGS += $(call cc-nowarn,address-of-packed-member)
-SPEC_CFLAGS += $(call cc-nowarn,null-dereference)
 SPEC_CFLAGS += $(call cc-nowarn,unused-label)
+SPEC_CFLAGS += $(call cc-nowarn,sign-compare)
+SPEC_CFLAGS += $(call cc-nowarn,unused-parameter)
+SPEC_CFLAGS += $(call cc-nowarn,old-style-declaration)
+SPEC_CFLAGS += $(call cc-nowarn,ignored-qualifiers)
+SPEC_CFLAGS += $(call cc-nowarn,clobbered)
+SPEC_CFLAGS += $(call cc-nowarn,missing-field-initializers)
+SPEC_CFLAGS += $(call cc-nowarn,implicit-fallthrough)
+SPEC_CFLAGS += $(call cc-opt,-Wtype-limits)
+SPEC_CFLAGS += $(call cc-opt,-Wshift-negative-value)
+SPEC_CFLAGS += $(call cc-opt,-Wshift-overflow=2)
+SPEC_CFLAGS += $(call cc-opt,-Wduplicated-cond)
+SPEC_CFLAGS += $(call cc-opt,-Wnull-dereference)
 
 #### Memory usage tuning
 # If small memory footprint is required, you can reduce the buffer size. There
@@ -806,7 +817,7 @@ EBTREE_DIR := ebtree
 
 #### Global compile options
 VERBOSE_CFLAGS = $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE)
-COPTS  = -Iinclude -I$(EBTREE_DIR) -Wall
+COPTS  = -Iinclude -I$(EBTREE_DIR) -Wall -Wextra
 COPTS += $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) $(SILENT_DEFINE)
 COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(ADDINC)