lazyload.h: use an even more generic function pointer than FARPROC
gcc will helpfully raise a -Wcast-function-type warning when casting between functions that might have incompatible return types (ex: GetUserNameExW returns bool which is only half the size of the return type from FARPROC which is long long), so create a new type that could be used as a completely generic function pointer and cast through it instead. Additionaly remove the -Wno-incompatible-pointer-types temporary flag added in 27e0c3c (win32: allow building with pedantic mode enabled, 2021-09-03), as it will be no longer needed. Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Carlo Marcelo Arenas Belón committed
Sep 26, 2021 at 03:05 UTC
2d84c4ed571215f4cdd5ea05a46861974d10d123
2 files changed
+6
-4
compat/win32/lazyload.h
+6
-3
@@ -15,10 +15,12 @@
15
* source, target);
16
*/
17
18
+typedef void (*FARVOIDPROC)(void);
19
+
20
struct proc_addr {
21
const char *const dll;
22
const char *const function;
21
- FARPROC pfunction;
23
+ FARVOIDPROC pfunction;
24
unsigned initialized : 1;
25
};
26
@@ -38,7 +40,7 @@ struct proc_addr {
40
#define INIT_PROC_ADDR(function) \
41
(function = (proc_type_##function)get_proc_addr(&proc_addr_##function))
42
41
-static inline FARPROC get_proc_addr(struct proc_addr *proc)
43
+static inline FARVOIDPROC get_proc_addr(struct proc_addr *proc)
44
{
45
/* only do this once */
46
if (!proc->initialized) {
@@ -47,7 +49,8 @@ static inline FARPROC get_proc_addr(struct proc_addr *proc)
49
hnd = LoadLibraryExA(proc->dll, NULL,
50
LOAD_LIBRARY_SEARCH_SYSTEM32);
51
if (hnd)
50
- proc->pfunction = GetProcAddress(hnd, proc->function);
52
+ proc->pfunction = (FARVOIDPROC)GetProcAddress(hnd,
53
+ proc->function);
54
}
55
/* set ENOSYS if DLL or function was not found */
56
if (!proc->pfunction)
config.mak.dev
-1
@@ -12,7 +12,6 @@ DEVELOPER_CFLAGS += -pedantic
12
DEVELOPER_CFLAGS += -Wpedantic
13
ifneq ($(filter gcc5,$(COMPILER_FEATURES)),)
14
DEVELOPER_CFLAGS += -Wno-pedantic-ms-format
15
-DEVELOPER_CFLAGS += -Wno-incompatible-pointer-types
15
endif
16
endif
17
DEVELOPER_CFLAGS += -Wdeclaration-after-statement