system_win32: fix a function pointer assignment warning
- Use CURLX_FUNCTION_CAST to suppress a function pointer assignment
warning.
a6bbc87f added lookups of some Windows API functions and then cast them
like `*(FARPROC*)&Curl_funcname = address`. Some versions of gcc warn
about that as breaking strict-aliasing rules so this PR changes those
assignments to use CURLX_FUNCTION_CAST.
Bug: https://github.com/curl/curl/pull/12581#issuecomment-1869804317
Reported-by: Marcel Raad
Closes https://github.com/curl/curl/pull/12602
This commit is contained in:
parent
aa2c2ab837
commit
26f002e02e
@ -43,21 +43,17 @@ bool Curl_isWindows8OrGreater;
|
|||||||
/* Handle of iphlpapp.dll */
|
/* Handle of iphlpapp.dll */
|
||||||
static HMODULE s_hIpHlpApiDll = NULL;
|
static HMODULE s_hIpHlpApiDll = NULL;
|
||||||
|
|
||||||
/* Pointer to the if_nametoindex function */
|
/* Function pointers */
|
||||||
IF_NAMETOINDEX_FN Curl_if_nametoindex = NULL;
|
IF_NAMETOINDEX_FN Curl_if_nametoindex = NULL;
|
||||||
|
FREEADDRINFOEXW_FN Curl_FreeAddrInfoExW = NULL;
|
||||||
void(WSAAPI *Curl_FreeAddrInfoExW)(ADDRINFOEXW_ *pAddrInfoEx) = NULL;
|
GETADDRINFOEXCANCEL_FN Curl_GetAddrInfoExCancel = NULL;
|
||||||
int(WSAAPI *Curl_GetAddrInfoExCancel)(LPHANDLE lpHandle) = NULL;
|
GETADDRINFOEXW_FN Curl_GetAddrInfoExW = NULL;
|
||||||
int(WSAAPI *Curl_GetAddrInfoExW)(PCWSTR pName, PCWSTR pServiceName,
|
|
||||||
DWORD dwNameSpace, LPGUID lpNspId, const ADDRINFOEXW_ *hints,
|
|
||||||
ADDRINFOEXW_ **ppResult, struct timeval *timeout, LPOVERLAPPED lpOverlapped,
|
|
||||||
LOOKUP_COMPLETION lpCompletionRoutine, LPHANDLE lpHandle) = NULL;
|
|
||||||
|
|
||||||
/* Curl_win32_init() performs win32 global initialization */
|
/* Curl_win32_init() performs win32 global initialization */
|
||||||
CURLcode Curl_win32_init(long flags)
|
CURLcode Curl_win32_init(long flags)
|
||||||
{
|
{
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
HANDLE ws2_32Dll;
|
HMODULE ws2_32Dll;
|
||||||
#endif
|
#endif
|
||||||
/* CURL_GLOBAL_WIN32 controls the *optional* part of the initialization which
|
/* CURL_GLOBAL_WIN32 controls the *optional* part of the initialization which
|
||||||
is just for Winsock at the moment. Any required win32 initialization
|
is just for Winsock at the moment. Any required win32 initialization
|
||||||
@ -118,12 +114,12 @@ CURLcode Curl_win32_init(long flags)
|
|||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
ws2_32Dll = GetModuleHandleA("ws2_32");
|
ws2_32Dll = GetModuleHandleA("ws2_32");
|
||||||
if(ws2_32Dll) {
|
if(ws2_32Dll) {
|
||||||
*(FARPROC*)&Curl_FreeAddrInfoExW = GetProcAddress(ws2_32Dll,
|
Curl_FreeAddrInfoExW = CURLX_FUNCTION_CAST(FREEADDRINFOEXW_FN,
|
||||||
"FreeAddrInfoExW");
|
GetProcAddress(ws2_32Dll, "FreeAddrInfoExW"));
|
||||||
*(FARPROC*)&Curl_GetAddrInfoExCancel = GetProcAddress(ws2_32Dll,
|
Curl_GetAddrInfoExCancel = CURLX_FUNCTION_CAST(GETADDRINFOEXCANCEL_FN,
|
||||||
"GetAddrInfoExCancel");
|
GetProcAddress(ws2_32Dll, "GetAddrInfoExCancel"));
|
||||||
*(FARPROC*)&Curl_GetAddrInfoExW = GetProcAddress(ws2_32Dll,
|
Curl_GetAddrInfoExW = CURLX_FUNCTION_CAST(GETADDRINFOEXW_FN,
|
||||||
"GetAddrInfoExW");
|
GetProcAddress(ws2_32Dll, "GetAddrInfoExW"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -57,12 +57,16 @@ typedef struct addrinfoexW_
|
|||||||
struct addrinfoexW_ *ai_next;
|
struct addrinfoexW_ *ai_next;
|
||||||
} ADDRINFOEXW_;
|
} ADDRINFOEXW_;
|
||||||
|
|
||||||
typedef void(CALLBACK *LOOKUP_COMPLETION)(DWORD, DWORD, LPWSAOVERLAPPED);
|
typedef void (CALLBACK *LOOKUP_COMPLETION_FN)(DWORD, DWORD, LPWSAOVERLAPPED);
|
||||||
extern void(WSAAPI *Curl_FreeAddrInfoExW)(ADDRINFOEXW_*);
|
typedef void (WSAAPI *FREEADDRINFOEXW_FN)(ADDRINFOEXW_*);
|
||||||
extern int(WSAAPI *Curl_GetAddrInfoExCancel)(LPHANDLE);
|
typedef int (WSAAPI *GETADDRINFOEXCANCEL_FN)(LPHANDLE);
|
||||||
extern int(WSAAPI *Curl_GetAddrInfoExW)(PCWSTR, PCWSTR, DWORD, LPGUID,
|
typedef int (WSAAPI *GETADDRINFOEXW_FN)(PCWSTR, PCWSTR, DWORD, LPGUID,
|
||||||
const ADDRINFOEXW_*, ADDRINFOEXW_**, struct timeval*, LPOVERLAPPED,
|
const ADDRINFOEXW_*, ADDRINFOEXW_**, struct timeval*, LPOVERLAPPED,
|
||||||
LOOKUP_COMPLETION, LPHANDLE);
|
LOOKUP_COMPLETION_FN, LPHANDLE);
|
||||||
|
|
||||||
|
extern FREEADDRINFOEXW_FN Curl_FreeAddrInfoExW;
|
||||||
|
extern GETADDRINFOEXCANCEL_FN Curl_GetAddrInfoExCancel;
|
||||||
|
extern GETADDRINFOEXW_FN Curl_GetAddrInfoExW;
|
||||||
|
|
||||||
/* This is used to dynamically load DLLs */
|
/* This is used to dynamically load DLLs */
|
||||||
HMODULE Curl_load_library(LPCTSTR filename);
|
HMODULE Curl_load_library(LPCTSTR filename);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user