[warnings] fix function pointer casts

This commit is contained in:
akallabeth 2024-08-30 14:07:46 +02:00
parent d02a30e377
commit 190929c018
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
14 changed files with 120 additions and 54 deletions

View File

@ -54,7 +54,13 @@ static void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABL
{ {
if (strcmp(pEntry->name, identifier) == 0) if (strcmp(pEntry->name, identifier) == 0)
{ {
return (void*)pEntry->entry; union
{
void* pv;
UINT (*entry)();
} cnv;
cnv.entry = pEntry->entry;
return cnv.pv;
} }
pEntry = &table->table[index++]; pEntry = &table->table[index++];

View File

@ -28,13 +28,17 @@
static ITSMFAudioDevice* tsmf_load_audio_device_by_name(const char* name, const char* device) static ITSMFAudioDevice* tsmf_load_audio_device_by_name(const char* name, const char* device)
{ {
ITSMFAudioDevice* audio = NULL; ITSMFAudioDevice* audio = NULL;
TSMF_AUDIO_DEVICE_ENTRY entry = union
(TSMF_AUDIO_DEVICE_ENTRY)(void*)freerdp_load_channel_addin_entry("tsmf", name, "audio", 0); {
PVIRTUALCHANNELENTRY pvce;
TSMF_AUDIO_DEVICE_ENTRY entry;
} cnv;
cnv.pvce = freerdp_load_channel_addin_entry("tsmf", name, "audio", 0);
if (!entry) if (!cnv.entry)
return NULL; return NULL;
const UINT rc = entry(&audio); const UINT rc = cnv.entry(&audio);
if ((rc != CHANNEL_RC_OK) || !audio) if ((rc != CHANNEL_RC_OK) || !audio)
{ {

View File

@ -33,13 +33,17 @@
static ITSMFDecoder* tsmf_load_decoder_by_name(const char* name) static ITSMFDecoder* tsmf_load_decoder_by_name(const char* name)
{ {
ITSMFDecoder* decoder = NULL; ITSMFDecoder* decoder = NULL;
TSMF_DECODER_ENTRY entry = union
(TSMF_DECODER_ENTRY)(void*)freerdp_load_channel_addin_entry("tsmf", name, "decoder", 0); {
PVIRTUALCHANNELENTRY pvce;
TSMF_DECODER_ENTRY entry;
} cnv;
cnv.pvce = freerdp_load_channel_addin_entry("tsmf", name, "decoder", 0);
if (!entry) if (!cnv.entry)
return NULL; return NULL;
const UINT rc = entry(&decoder); const UINT rc = cnv.entry(&decoder);
if ((rc != CHANNEL_RC_OK) || !decoder) if ((rc != CHANNEL_RC_OK) || !decoder)
{ {

View File

@ -5716,17 +5716,22 @@ fail:
static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* settings, static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* settings,
const char* name, void* data) const char* name, void* data)
{ {
union
{
PVIRTUALCHANNELENTRY pvce;
PVIRTUALCHANNELENTRYEX pvceex;
} cnv;
PVIRTUALCHANNELENTRY entry = NULL; PVIRTUALCHANNELENTRY entry = NULL;
PVIRTUALCHANNELENTRYEX entryEx =
(PVIRTUALCHANNELENTRYEX)(void*)freerdp_load_channel_addin_entry(
name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
if (!entryEx) cnv.pvce = freerdp_load_channel_addin_entry(
name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
if (!cnv.pvceex)
entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC); entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
if (entryEx) if (cnv.pvceex)
{ {
if (freerdp_channels_client_load_ex(channels, settings, entryEx, data) == 0) if (freerdp_channels_client_load_ex(channels, settings, cnv.pvceex, data) == 0)
{ {
WLog_DBG(TAG, "loading channelEx %s", name); WLog_DBG(TAG, "loading channelEx %s", name);
return TRUE; return TRUE;

View File

@ -237,7 +237,13 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPa
if (!library) if (!library)
goto fail; goto fail;
entry = (PVIRTUALCHANNELENTRY)GetProcAddress(library, pszEntryName); union
{
FARPROC fp;
PVIRTUALCHANNELENTRY entry;
} cnv;
cnv.fp = GetProcAddress(library, pszEntryName);
entry = cnv.entry;
fail: fail:
free(pszRelativeFilePath); free(pszRelativeFilePath);
free(pszAddinFile); free(pszAddinFile);

View File

@ -468,16 +468,19 @@ static BOOL createChildSessionTransport(HANDLE* pFile)
WCHAR pipePath[0x80] = { 0 }; WCHAR pipePath[0x80] = { 0 };
char pipePathA[0x80] = { 0 }; char pipePathA[0x80] = { 0 };
WinStationCreateChildSessionTransportFn createChildSessionFn = union
(WinStationCreateChildSessionTransportFn)GetProcAddress( {
hModule, "WinStationCreateChildSessionTransport"); FARPROC fp;
if (!createChildSessionFn) WinStationCreateChildSessionTransportFn createChildSessionFn;
} cnv;
cnv.fp = GetProcAddress(hModule, "WinStationCreateChildSessionTransport");
if (!cnv.createChildSessionFn)
{ {
WLog_ERR(TAG, "unable to retrieve WinStationCreateChildSessionTransport function"); WLog_ERR(TAG, "unable to retrieve WinStationCreateChildSessionTransport function");
goto out; goto out;
} }
HRESULT hStatus = createChildSessionFn(pipePath, 0x80); HRESULT hStatus = cnv.createChildSessionFn(pipePath, 0x80);
if (!SUCCEEDED(hStatus)) if (!SUCCEEDED(hStatus))
{ {
WLog_ERR(TAG, "error 0x%x when creating childSessionTransport", hStatus); WLog_ERR(TAG, "error 0x%x when creating childSessionTransport", hStatus);

View File

@ -796,7 +796,6 @@ static SecurityFunctionTable* auth_resolve_sspi_table(const rdpSettings* setting
if (sspi_module || settings->SspiModule) if (sspi_module || settings->SspiModule)
{ {
INIT_SECURITY_INTERFACE InitSecurityInterface_ptr = NULL;
const char* module_name = sspi_module ? sspi_module : settings->SspiModule; const char* module_name = sspi_module ? sspi_module : settings->SspiModule;
#ifdef UNICODE #ifdef UNICODE
const char* proc_name = "InitSecurityInterfaceW"; const char* proc_name = "InitSecurityInterfaceW";
@ -815,10 +814,20 @@ static SecurityFunctionTable* auth_resolve_sspi_table(const rdpSettings* setting
WLog_INFO(TAG, "Using SSPI Module: %s", module_name); WLog_INFO(TAG, "Using SSPI Module: %s", module_name);
InitSecurityInterface_ptr = (INIT_SECURITY_INTERFACE)GetProcAddress(hSSPI, proc_name); union
{
FARPROC fp;
INIT_SECURITY_INTERFACE InitSecurityInterface_ptr;
} cnv;
cnv.fp = GetProcAddress(hSSPI, proc_name);
if (!cnv.InitSecurityInterface_ptr)
{
WLog_ERR(TAG, "Failed to load SSPI module: %s, no function %s", module_name, proc_name);
free(sspi_module);
return FALSE;
}
free(sspi_module); free(sspi_module);
return InitSecurityInterface_ptr(); return cnv.InitSecurityInterface_ptr();
} }
return InitSecurityInterfaceEx(0); return InitSecurityInterfaceEx(0);

View File

@ -97,8 +97,10 @@ struct rdp_transport
BOOL earlyUserAuth; BOOL earlyUserAuth;
}; };
static void transport_ssl_cb(SSL* ssl, int where, int ret) static int transport_ssl_cb(BIO* bio, int where, int ret)
{ {
SSL* ssl = (SSL*)bio;
if (where & SSL_CB_ALERT) if (where & SSL_CB_ALERT)
{ {
rdpTransport* transport = (rdpTransport*)SSL_get_app_data(ssl); rdpTransport* transport = (rdpTransport*)SSL_get_app_data(ssl);
@ -145,6 +147,7 @@ static void transport_ssl_cb(SSL* ssl, int where, int ret)
} }
} }
} }
return 0;
} }
wStream* transport_send_stream_init(rdpTransport* transport, size_t size) wStream* transport_send_stream_init(rdpTransport* transport, size_t size)
@ -326,7 +329,7 @@ static BOOL transport_default_connect_tls(rdpTransport* transport)
} }
transport->frontBio = tls->bio; transport->frontBio = tls->bio;
BIO_callback_ctrl(tls->bio, BIO_CTRL_SET_CALLBACK, (bio_info_cb*)(void*)transport_ssl_cb); BIO_callback_ctrl(tls->bio, BIO_CTRL_SET_CALLBACK, transport_ssl_cb);
SSL_set_app_data(tls->ssl, transport); SSL_set_app_data(tls->ssl, transport);
if (!transport->frontBio) if (!transport->frontBio)

View File

@ -517,12 +517,11 @@ static int bio_rdp_tls_free(BIO* bio)
static long bio_rdp_tls_callback_ctrl(BIO* bio, int cmd, bio_info_cb* fp) static long bio_rdp_tls_callback_ctrl(BIO* bio, int cmd, bio_info_cb* fp)
{ {
long status = 0; long status = 0;
BIO_RDP_TLS* tls = NULL;
if (!bio) if (!bio)
return 0; return 0;
tls = (BIO_RDP_TLS*)BIO_get_data(bio); BIO_RDP_TLS* tls = (BIO_RDP_TLS*)BIO_get_data(bio);
if (!tls) if (!tls)
return 0; return 0;
@ -535,8 +534,14 @@ static long bio_rdp_tls_callback_ctrl(BIO* bio, int cmd, bio_info_cb* fp)
/* Documented since https://www.openssl.org/docs/man1.1.1/man3/BIO_set_callback.html /* Documented since https://www.openssl.org/docs/man1.1.1/man3/BIO_set_callback.html
* the argument is not really of type bio_info_cb* and must be cast * the argument is not really of type bio_info_cb* and must be cast
* to the required type */ * to the required type */
fkt_t fkt = (fkt_t)(void*)fp; union
SSL_set_info_callback(tls->ssl, fkt); {
fkt_t fkt;
bio_info_cb* fp;
} cnv;
cnv.fp = fp;
SSL_set_info_callback(tls->ssl, cnv.fkt);
status = 1; status = 1;
} }
break; break;

View File

@ -194,16 +194,21 @@ static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpS
const char* name, void* data) const char* name, void* data)
{ {
PVIRTUALCHANNELENTRY entry = NULL; PVIRTUALCHANNELENTRY entry = NULL;
PVIRTUALCHANNELENTRYEX entryEx = NULL; union
entryEx = (PVIRTUALCHANNELENTRYEX)(void*)freerdp_load_channel_addin_entry( {
PVIRTUALCHANNELENTRY entry;
PVIRTUALCHANNELENTRYEX entryEx;
} cnv;
cnv.entry = freerdp_load_channel_addin_entry(
name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX); name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
if (!entryEx) if (!cnv.entryEx)
entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC); entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
if (entryEx) if (cnv.entryEx)
{ {
if (freerdp_channels_client_load_ex(channels, settings, entryEx, data) == 0) if (freerdp_channels_client_load_ex(channels, settings, cnv.entryEx, data) == 0)
{ {
WLog_INFO(TAG, "loading channelEx %s", name); WLog_INFO(TAG, "loading channelEx %s", name);
return TRUE; return TRUE;

View File

@ -481,11 +481,9 @@ void pf_modules_list_loaded_plugins(proxyModule* module)
static BOOL pf_modules_load_module(const char* module_path, proxyModule* module, void* userdata) static BOOL pf_modules_load_module(const char* module_path, proxyModule* module, void* userdata)
{ {
HMODULE handle = NULL;
proxyModuleEntryPoint pEntryPoint = NULL;
WINPR_ASSERT(module); WINPR_ASSERT(module);
handle = LoadLibraryX(module_path); HANDLE handle = LoadLibraryX(module_path);
if (handle == NULL) if (handle == NULL)
{ {
@ -493,8 +491,13 @@ static BOOL pf_modules_load_module(const char* module_path, proxyModule* module,
return FALSE; return FALSE;
} }
pEntryPoint = (proxyModuleEntryPoint)GetProcAddress(handle, MODULE_ENTRY_POINT); union
if (!pEntryPoint) {
FARPROC fp;
proxyModuleEntryPoint pEntryPoint;
} cnv;
cnv.fp = GetProcAddress(handle, MODULE_ENTRY_POINT);
if (!cnv.pEntryPoint)
{ {
WLog_ERR(TAG, "GetProcAddress failed while loading %s", module_path); WLog_ERR(TAG, "GetProcAddress failed while loading %s", module_path);
goto error; goto error;
@ -504,7 +507,7 @@ static BOOL pf_modules_load_module(const char* module_path, proxyModule* module,
WLog_ERR(TAG, "ArrayList_Append failed!"); WLog_ERR(TAG, "ArrayList_Append failed!");
goto error; goto error;
} }
return pf_modules_add(module, pEntryPoint, userdata); return pf_modules_add(module, cnv.pEntryPoint, userdata);
error: error:
FreeLibrary(handle); FreeLibrary(handle);

View File

@ -1252,7 +1252,6 @@ SECURITY_STATUS NCryptOpenP11StorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
const char* modulePath = *modulePaths++; const char* modulePath = *modulePaths++;
HANDLE library = LoadLibrary(modulePath); HANDLE library = LoadLibrary(modulePath);
typedef CK_RV (*c_get_function_list_t)(CK_FUNCTION_LIST_PTR_PTR); typedef CK_RV (*c_get_function_list_t)(CK_FUNCTION_LIST_PTR_PTR);
c_get_function_list_t c_get_function_list = NULL;
NCryptP11ProviderHandle* provider = NULL; NCryptP11ProviderHandle* provider = NULL;
WLog_DBG(TAG, "Trying pkcs11 module '%s'", modulePath); WLog_DBG(TAG, "Trying pkcs11 module '%s'", modulePath);
@ -1262,14 +1261,20 @@ SECURITY_STATUS NCryptOpenP11StorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
goto out_load_library; goto out_load_library;
} }
c_get_function_list = (c_get_function_list_t)GetProcAddress(library, "C_GetFunctionList"); union
if (!c_get_function_list) {
FARPROC fp;
c_get_function_list_t c_get_function_list;
} cnv;
cnv.fp = GetProcAddress(library, "C_GetFunctionList");
if (!cnv.c_get_function_list)
{ {
status = NTE_PROV_TYPE_ENTRY_BAD; status = NTE_PROV_TYPE_ENTRY_BAD;
goto out_load_library; goto out_load_library;
} }
status = initialize_pkcs11(library, c_get_function_list, phProvider); status = initialize_pkcs11(library, cnv.c_get_function_list, phProvider);
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
{ {
status = NTE_PROVIDER_DLL_FAIL; status = NTE_PROVIDER_DLL_FAIL;

View File

@ -527,7 +527,13 @@ static void* thread_launcher(void* arg)
if (!(fkt = thread->lpStartAddress)) if (!(fkt = thread->lpStartAddress))
{ {
WLog_ERR(TAG, "Thread function argument is %p", (void*)fkt); union
{
LPTHREAD_START_ROUTINE fkt;
void* pv;
} cnv;
cnv.fkt = fkt;
WLog_ERR(TAG, "Thread function argument is %p", cnv.pv);
goto exit; goto exit;
} }

View File

@ -695,20 +695,22 @@ BOOL WTSRegisterWtsApiFunctionTable(const WtsApiFunctionTable* table)
static BOOL LoadAndInitialize(char* library) static BOOL LoadAndInitialize(char* library)
{ {
INIT_WTSAPI_FN pInitWtsApi = NULL;
g_WtsApiModule = LoadLibraryX(library); g_WtsApiModule = LoadLibraryX(library);
if (!g_WtsApiModule) if (!g_WtsApiModule)
return FALSE; return FALSE;
pInitWtsApi = (INIT_WTSAPI_FN)GetProcAddress(g_WtsApiModule, "InitWtsApi"); union
if (!pInitWtsApi)
{ {
return FALSE; FARPROC fp;
} INIT_WTSAPI_FN pInitWtsApi;
} cnv;
cnv.fp = GetProcAddress(g_WtsApiModule, "InitWtsApi");
g_WtsApi = pInitWtsApi(); if (!cnv.pInitWtsApi)
return FALSE;
g_WtsApi = cnv.pInitWtsApi();
return TRUE; return TRUE;
} }