mirror of
https://github.com/git/git.git
synced 2026-01-10 18:20:27 +00:00
801fa63a90 ("config.mak.dev: add -Wformat-security", 2018-09-08)
added the "-Wformat-security" to the flags set in config.mak.dev.
In the gcc man page this is documented as:
If -Wformat is specified, also warn about uses of format
functions that represent possible security problems. [...]
The commit did however not add the "-Wformat" flag, but instead
relied on the fact that "-Wall" is set in the Makefile by default
and that "-Wformat" is part of "-Wall".
Unfortunately, those who use config.mak.autogen generated with the
autoconf to configure toolchain do *not* get "-Wall" in their CFLAGS
and the added -Wformat-security had no effect. Worse yet, newer
versions of gcc (gcc 8.2.1 in this particular case) warn about the
lack of "-Wformat" and thus compilation fails only with this option
set.
We could fix it by adding "-Wformat", but in general we do want all
checks included in "-Wall", so let's add it to config.mak.dev to
cover more cases.
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
45 lines
1.3 KiB
Plaintext
45 lines
1.3 KiB
Plaintext
ifeq ($(filter no-error,$(DEVOPTS)),)
|
|
CFLAGS += -Werror
|
|
endif
|
|
CFLAGS += -Wall
|
|
CFLAGS += -Wdeclaration-after-statement
|
|
CFLAGS += -Wformat-security
|
|
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-function
|
|
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
|