]> git.ipfire.org Git - thirdparty/git.git/commitdiff
lazyload.h: use an even more generic function pointer than FARPROC
authorCarlo Marcelo Arenas Belón <carenas@gmail.com>
Sun, 26 Sep 2021 10:05:12 +0000 (03:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Sep 2021 20:13:58 +0000 (13:13 -0700)
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>
compat/win32/lazyload.h
config.mak.dev

index 121ee24ed2d96e998fbaeccf3785e05dafb44398..2b3637135f68a3e7c2acadf0971e143cf689db02 100644 (file)
  *                        source, target);
  */
 
+typedef void (*FARVOIDPROC)(void);
+
 struct proc_addr {
        const char *const dll;
        const char *const function;
-       FARPROC pfunction;
+       FARVOIDPROC pfunction;
        unsigned initialized : 1;
 };
 
@@ -38,7 +40,7 @@ struct proc_addr {
 #define INIT_PROC_ADDR(function) \
        (function = (proc_type_##function)get_proc_addr(&proc_addr_##function))
 
-static inline FARPROC get_proc_addr(struct proc_addr *proc)
+static inline FARVOIDPROC get_proc_addr(struct proc_addr *proc)
 {
        /* only do this once */
        if (!proc->initialized) {
@@ -47,7 +49,8 @@ static inline FARPROC get_proc_addr(struct proc_addr *proc)
                hnd = LoadLibraryExA(proc->dll, NULL,
                                     LOAD_LIBRARY_SEARCH_SYSTEM32);
                if (hnd)
-                       proc->pfunction = GetProcAddress(hnd, proc->function);
+                       proc->pfunction = (FARVOIDPROC)GetProcAddress(hnd,
+                                                       proc->function);
        }
        /* set ENOSYS if DLL or function was not found */
        if (!proc->pfunction)
index c080ac0231739479b4f49c03514663a2e5411161..cdf043c52bba99301ff8fc74c100d4672fa5a401 100644 (file)
@@ -12,7 +12,6 @@ DEVELOPER_CFLAGS += -pedantic
 DEVELOPER_CFLAGS += -Wpedantic
 ifneq ($(filter gcc5,$(COMPILER_FEATURES)),)
 DEVELOPER_CFLAGS += -Wno-pedantic-ms-format
-DEVELOPER_CFLAGS += -Wno-incompatible-pointer-types
 endif
 endif
 DEVELOPER_CFLAGS += -Wdeclaration-after-statement