win32: allow building with pedantic mode enabled

In preparation to building with pedantic mode enabled, change a couple
of places where the current mingw gcc compiler provided with the SDK
reports issues.

A full fix for the incompatible use of (void *) to store function
pointers has been punted, with the minimal change to instead use a
generic function pointer (FARPROC), and therefore the (hopefully)
temporary need to disable incompatible pointer warnings.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Carlo Marcelo Arenas Belón 2021-09-03 10:02:31 -07:00 коммит произвёл Junio C Hamano
Родитель 153fb49e60
Коммит 27e0c3c6cf
3 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

@ -510,7 +510,7 @@ static void threadcache_free(nedpool *p, threadcache *tc, int mymspace, void *me
assert(idx<=THREADCACHEMAXBINS); assert(idx<=THREADCACHEMAXBINS);
if(tck==*binsptr) if(tck==*binsptr)
{ {
fprintf(stderr, "Attempt to free already freed memory block %p - aborting!\n", tck); fprintf(stderr, "Attempt to free already freed memory block %p - aborting!\n", (void *)tck);
abort(); abort();
} }
#ifdef FULLSANITYCHECKS #ifdef FULLSANITYCHECKS

Просмотреть файл

@ -37,7 +37,7 @@ struct proc_addr {
#define INIT_PROC_ADDR(function) \ #define INIT_PROC_ADDR(function) \
(function = get_proc_addr(&proc_addr_##function)) (function = get_proc_addr(&proc_addr_##function))
static inline void *get_proc_addr(struct proc_addr *proc) static inline FARPROC get_proc_addr(struct proc_addr *proc)
{ {
/* only do this once */ /* only do this once */
if (!proc->initialized) { if (!proc->initialized) {

Просмотреть файл

@ -1,11 +1,18 @@
ifndef COMPILER_FEATURES
COMPILER_FEATURES := $(shell ./detect-compiler $(CC))
endif
ifeq ($(filter no-error,$(DEVOPTS)),) ifeq ($(filter no-error,$(DEVOPTS)),)
DEVELOPER_CFLAGS += -Werror DEVELOPER_CFLAGS += -Werror
SPARSE_FLAGS += -Wsparse-error SPARSE_FLAGS += -Wsparse-error
endif endif
DEVELOPER_CFLAGS += -Wall
ifneq ($(filter pedantic,$(DEVOPTS)),) ifneq ($(filter pedantic,$(DEVOPTS)),)
DEVELOPER_CFLAGS += -pedantic DEVELOPER_CFLAGS += -pedantic
ifneq ($(filter gcc5,$(COMPILER_FEATURES)),)
DEVELOPER_CFLAGS += -Wno-incompatible-pointer-types
endif
endif endif
DEVELOPER_CFLAGS += -Wall
DEVELOPER_CFLAGS += -Wdeclaration-after-statement DEVELOPER_CFLAGS += -Wdeclaration-after-statement
DEVELOPER_CFLAGS += -Wformat-security DEVELOPER_CFLAGS += -Wformat-security
DEVELOPER_CFLAGS += -Wold-style-definition DEVELOPER_CFLAGS += -Wold-style-definition
@ -16,10 +23,6 @@ DEVELOPER_CFLAGS += -Wunused
DEVELOPER_CFLAGS += -Wvla DEVELOPER_CFLAGS += -Wvla
DEVELOPER_CFLAGS += -fno-common DEVELOPER_CFLAGS += -fno-common
ifndef COMPILER_FEATURES
COMPILER_FEATURES := $(shell ./detect-compiler $(CC))
endif
ifneq ($(filter clang4,$(COMPILER_FEATURES)),) ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare
endif endif