[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)
{
return (void*)pEntry->entry;
union
{
void* pv;
UINT (*entry)();
} cnv;
cnv.entry = pEntry->entry;
return cnv.pv;
}
pEntry = &table->table[index++];

View File

@ -28,13 +28,17 @@
static ITSMFAudioDevice* tsmf_load_audio_device_by_name(const char* name, const char* device)
{
ITSMFAudioDevice* audio = NULL;
TSMF_AUDIO_DEVICE_ENTRY entry =
(TSMF_AUDIO_DEVICE_ENTRY)(void*)freerdp_load_channel_addin_entry("tsmf", name, "audio", 0);
union
{
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;
const UINT rc = entry(&audio);
const UINT rc = cnv.entry(&audio);
if ((rc != CHANNEL_RC_OK) || !audio)
{

View File

@ -33,13 +33,17 @@
static ITSMFDecoder* tsmf_load_decoder_by_name(const char* name)
{
ITSMFDecoder* decoder = NULL;
TSMF_DECODER_ENTRY entry =
(TSMF_DECODER_ENTRY)(void*)freerdp_load_channel_addin_entry("tsmf", name, "decoder", 0);
union
{
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;
const UINT rc = entry(&decoder);
const UINT rc = cnv.entry(&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,
const char* name, void* data)
{
union
{
PVIRTUALCHANNELENTRY pvce;
PVIRTUALCHANNELENTRYEX pvceex;
} cnv;
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);
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);
return TRUE;

View File

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

View File

@ -468,16 +468,19 @@ static BOOL createChildSessionTransport(HANDLE* pFile)
WCHAR pipePath[0x80] = { 0 };
char pipePathA[0x80] = { 0 };
WinStationCreateChildSessionTransportFn createChildSessionFn =
(WinStationCreateChildSessionTransportFn)GetProcAddress(
hModule, "WinStationCreateChildSessionTransport");
if (!createChildSessionFn)
union
{
FARPROC fp;
WinStationCreateChildSessionTransportFn createChildSessionFn;
} cnv;
cnv.fp = GetProcAddress(hModule, "WinStationCreateChildSessionTransport");
if (!cnv.createChildSessionFn)
{
WLog_ERR(TAG, "unable to retrieve WinStationCreateChildSessionTransport function");
goto out;
}
HRESULT hStatus = createChildSessionFn(pipePath, 0x80);
HRESULT hStatus = cnv.createChildSessionFn(pipePath, 0x80);
if (!SUCCEEDED(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)
{
INIT_SECURITY_INTERFACE InitSecurityInterface_ptr = NULL;
const char* module_name = sspi_module ? sspi_module : settings->SspiModule;
#ifdef UNICODE
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);
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);
return InitSecurityInterface_ptr();
return cnv.InitSecurityInterface_ptr();
}
return InitSecurityInterfaceEx(0);

View File

@ -97,8 +97,10 @@ struct rdp_transport
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)
{
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)
@ -326,7 +329,7 @@ static BOOL transport_default_connect_tls(rdpTransport* transport)
}
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);
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)
{
long status = 0;
BIO_RDP_TLS* tls = NULL;
if (!bio)
return 0;
tls = (BIO_RDP_TLS*)BIO_get_data(bio);
BIO_RDP_TLS* tls = (BIO_RDP_TLS*)BIO_get_data(bio);
if (!tls)
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
* the argument is not really of type bio_info_cb* and must be cast
* to the required type */
fkt_t fkt = (fkt_t)(void*)fp;
SSL_set_info_callback(tls->ssl, fkt);
union
{
fkt_t fkt;
bio_info_cb* fp;
} cnv;
cnv.fp = fp;
SSL_set_info_callback(tls->ssl, cnv.fkt);
status = 1;
}
break;

View File

@ -194,16 +194,21 @@ static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpS
const char* name, void* data)
{
PVIRTUALCHANNELENTRY entry = NULL;
PVIRTUALCHANNELENTRYEX entryEx = NULL;
entryEx = (PVIRTUALCHANNELENTRYEX)(void*)freerdp_load_channel_addin_entry(
union
{
PVIRTUALCHANNELENTRY entry;
PVIRTUALCHANNELENTRYEX entryEx;
} cnv;
cnv.entry = freerdp_load_channel_addin_entry(
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);
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);
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)
{
HMODULE handle = NULL;
proxyModuleEntryPoint pEntryPoint = NULL;
WINPR_ASSERT(module);
handle = LoadLibraryX(module_path);
HANDLE handle = LoadLibraryX(module_path);
if (handle == NULL)
{
@ -493,8 +491,13 @@ static BOOL pf_modules_load_module(const char* module_path, proxyModule* module,
return FALSE;
}
pEntryPoint = (proxyModuleEntryPoint)GetProcAddress(handle, MODULE_ENTRY_POINT);
if (!pEntryPoint)
union
{
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);
goto error;
@ -504,7 +507,7 @@ static BOOL pf_modules_load_module(const char* module_path, proxyModule* module,
WLog_ERR(TAG, "ArrayList_Append failed!");
goto error;
}
return pf_modules_add(module, pEntryPoint, userdata);
return pf_modules_add(module, cnv.pEntryPoint, userdata);
error:
FreeLibrary(handle);

View File

@ -1252,7 +1252,6 @@ SECURITY_STATUS NCryptOpenP11StorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
const char* modulePath = *modulePaths++;
HANDLE library = LoadLibrary(modulePath);
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;
WLog_DBG(TAG, "Trying pkcs11 module '%s'", modulePath);
@ -1262,14 +1261,20 @@ SECURITY_STATUS NCryptOpenP11StorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
goto out_load_library;
}
c_get_function_list = (c_get_function_list_t)GetProcAddress(library, "C_GetFunctionList");
if (!c_get_function_list)
union
{
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;
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)
{
status = NTE_PROVIDER_DLL_FAIL;

View File

@ -527,7 +527,13 @@ static void* thread_launcher(void* arg)
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;
}

View File

@ -695,20 +695,22 @@ BOOL WTSRegisterWtsApiFunctionTable(const WtsApiFunctionTable* table)
static BOOL LoadAndInitialize(char* library)
{
INIT_WTSAPI_FN pInitWtsApi = NULL;
g_WtsApiModule = LoadLibraryX(library);
if (!g_WtsApiModule)
return FALSE;
pInitWtsApi = (INIT_WTSAPI_FN)GetProcAddress(g_WtsApiModule, "InitWtsApi");
if (!pInitWtsApi)
union
{
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;
}