BUILD: build with -Wextra and sort out certain warnings

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.
This commit is contained in:
Willy Tarreau 2018-09-20 10:38:08 +02:00
parent 7d7ab43a33
commit f7db9305aa
1 changed files with 13 additions and 2 deletions

View File

@ -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)