git/config.mak.dev
Jeff King 36da893114 config.mak.dev: enable -Wunused-function
We explicitly omitted -Wunused-function when we added
-Wextra, but there is no need: the current code compiles
cleanly with it. And it's worth having, since it can let you
know when there are cascading effects from a cleanup (e.g.,
deleting one function lets you delete its static helpers).

There are cases where we may need an unused function to
exist, but we can handle these easily:

  - macro-generated code like commit-slab; there we have the
    MAYBE_UNUSED annotation to silence the compiler

  - conditional compilation, where we may or may not need a
    static helper. These generally fall into one of two
    categories:

      - the call should not be conditional, but rather the
	function body itself should be (and may just be a
	no-op on one side of the #if). That keeps the
	conditional pollution out of the main code.

      - call-chains of static helpers should all be in the
        same #if block, so they are all-or-nothing

    And if there's some case that doesn't cover, we still
    have MAYBE_UNUSED as a fallback.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-10-19 10:24:11 +09:00

47 lines
1.4 KiB
Plaintext

ifeq ($(filter no-error,$(DEVOPTS)),)
CFLAGS += -Werror
endif
ifneq ($(filter pedantic,$(DEVOPTS)),)
CFLAGS += -pedantic
# don't warn for each N_ use
CFLAGS += -DUSE_PARENS_AROUND_GETTEXT_N=0
endif
CFLAGS += -Wdeclaration-after-statement
CFLAGS += -Wno-format-zero-length
CFLAGS += -Wold-style-definition
CFLAGS += -Woverflow
CFLAGS += -Wpointer-arith
CFLAGS += -Wstrict-prototypes
CFLAGS += -Wunused
CFLAGS += -Wvla
ifndef COMPILER_FEATURES
COMPILER_FEATURES := $(shell ./detect-compiler $(CC))
endif
ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
CFLAGS += -Wtautological-constant-out-of-range-compare
endif
ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
CFLAGS += -Wextra
# if a function is public, there should be a prototype and the right
# header file should be included. If not, it should be static.
CFLAGS += -Wmissing-prototypes
ifeq ($(filter extra-all,$(DEVOPTS)),)
# These are disabled because we have these all over the place.
CFLAGS += -Wno-empty-body
CFLAGS += -Wno-missing-field-initializers
CFLAGS += -Wno-sign-compare
CFLAGS += -Wno-unused-parameter
endif
endif
# uninitialized warnings on gcc 4.9.2 in xdiff/xdiffi.c and config.c
# not worth fixing since newer compilers correctly stop complaining
ifneq ($(filter gcc4,$(COMPILER_FEATURES)),)
ifeq ($(filter gcc5,$(COMPILER_FEATURES)),)
CFLAGS += -Wno-uninitialized
endif
endif