Commit 759ec7d4fa3b5de7882dc1e69af3354fe014d1e0

Edward Thomson 2019-06-15T22:01:00

win32: cast GetProcAddress to void * before casting GetProcAddress is prototyped to return a `FARPROC`, which is meant to be a generic function pointer. It's literally `int (FAR WINAPI * FARPROC)()` which gcc complains if you attempt to cast to a `void (*)(GIT_SRWLOCK *)`. Cast to a `void *` before casting to avoid warnings about the arguments.

diff --git a/src/win32/thread.c b/src/win32/thread.c
index 2d96005..c3a6c0e 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -42,15 +42,15 @@ int git_threads_init(void)
 	HMODULE hModule = GetModuleHandleW(L"kernel32");
 
 	if (hModule) {
-		win32_srwlock_initialize = (win32_srwlock_fn)
+		win32_srwlock_initialize = (win32_srwlock_fn)(void *)
 			GetProcAddress(hModule, "InitializeSRWLock");
-		win32_srwlock_acquire_shared = (win32_srwlock_fn)
+		win32_srwlock_acquire_shared = (win32_srwlock_fn)(void *)
 			GetProcAddress(hModule, "AcquireSRWLockShared");
-		win32_srwlock_release_shared = (win32_srwlock_fn)
+		win32_srwlock_release_shared = (win32_srwlock_fn)(void *)
 			GetProcAddress(hModule, "ReleaseSRWLockShared");
-		win32_srwlock_acquire_exclusive = (win32_srwlock_fn)
+		win32_srwlock_acquire_exclusive = (win32_srwlock_fn)(void *)
 			GetProcAddress(hModule, "AcquireSRWLockExclusive");
-		win32_srwlock_release_exclusive = (win32_srwlock_fn)
+		win32_srwlock_release_exclusive = (win32_srwlock_fn)(void *)
 			GetProcAddress(hModule, "ReleaseSRWLockExclusive");
 	}