[function pointers] unify casts with macro

This commit is contained in:
akallabeth
2024-09-04 15:26:38 +02:00
parent 1a9766e190
commit 245afb706c
25 changed files with 135 additions and 194 deletions

View File

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

View File

@@ -491,13 +491,9 @@ static BOOL pf_modules_load_module(const char* module_path, proxyModule* module,
return FALSE;
}
union
{
FARPROC fp;
proxyModuleEntryPoint pEntryPoint;
} cnv;
cnv.fp = GetProcAddress(handle, MODULE_ENTRY_POINT);
if (!cnv.pEntryPoint)
FARPROC fp = GetProcAddress(handle, MODULE_ENTRY_POINT);
proxyModuleEntryPoint pEntryPoint = WINPR_FUNC_PTR_CAST(fp, proxyModuleEntryPoint);
if (!pEntryPoint)
{
WLog_ERR(TAG, "GetProcAddress failed while loading %s", module_path);
goto error;
@@ -507,7 +503,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, cnv.pEntryPoint, userdata);
return pf_modules_add(module, pEntryPoint, userdata);
error:
FreeLibrary(handle);