Merge pull request #10541 from akallabeth/warn-pedantic

Warn pedantic
This commit is contained in:
akallabeth 2024-08-31 11:33:24 +02:00 committed by GitHub
commit 6d8d4ddb1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
37 changed files with 248 additions and 123 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

@ -162,7 +162,11 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
UINT32 size = 0; UINT32 size = 0;
const BYTE* s = NULL; const BYTE* s = NULL;
TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder; TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
WINPR_PRAGMA_DIAG_PUSH
WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS
mdecoder->codec = avcodec_find_decoder(mdecoder->codec_id); mdecoder->codec = avcodec_find_decoder(mdecoder->codec_id);
WINPR_PRAGMA_DIAG_POP
if (!mdecoder->codec) if (!mdecoder->codec)
{ {

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

@ -1306,11 +1306,19 @@ static DWORD WINAPI xf_handle_pipe(void* arg)
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno); winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
return 0; return 0;
} }
WINPR_PRAGMA_DIAG_PUSH
WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS
freerdp_add_signal_cleanup_handler(pipe, cleanup_pipe); freerdp_add_signal_cleanup_handler(pipe, cleanup_pipe);
WINPR_PRAGMA_DIAG_POP
xf_process_pipe(context, pipe); xf_process_pipe(context, pipe);
WINPR_PRAGMA_DIAG_PUSH
WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS
freerdp_del_signal_cleanup_handler(pipe, cleanup_pipe); freerdp_del_signal_cleanup_handler(pipe, cleanup_pipe);
WINPR_PRAGMA_DIAG_POP
unlink(pipe); unlink(pipe);
return 0; return 0;
} }

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( cnv.pvce = 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.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

@ -1233,7 +1233,8 @@ void freerdp_dsp_context_free(FREERDP_DSP_CONTEXT* context)
BOOL freerdp_dsp_encode(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context, BOOL freerdp_dsp_encode(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context,
const AUDIO_FORMAT* WINPR_RESTRICT srcFormat, const AUDIO_FORMAT* WINPR_RESTRICT srcFormat,
const BYTE* WINPR_RESTRICT data, size_t length, wStream* WINPR_RESTRICT out) const BYTE* WINPR_RESTRICT pdata, size_t length,
wStream* WINPR_RESTRICT out)
{ {
#if defined(WITH_FDK_AAC) #if defined(WITH_FDK_AAC)
FREERDP_DSP_COMMON_CONTEXT* ctx = (FREERDP_DSP_COMMON_CONTEXT*)context; FREERDP_DSP_COMMON_CONTEXT* ctx = (FREERDP_DSP_COMMON_CONTEXT*)context;
@ -1241,27 +1242,28 @@ BOOL freerdp_dsp_encode(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context,
switch (ctx->format.wFormatTag) switch (ctx->format.wFormatTag)
{ {
case WAVE_FORMAT_AAC_MS: case WAVE_FORMAT_AAC_MS:
return fdk_aac_dsp_encode(ctx, srcFormat, data, length, out); return fdk_aac_dsp_encode(ctx, srcFormat, pdata, length, out);
default: default:
break; break;
} }
#endif #endif
#if defined(WITH_DSP_FFMPEG) #if defined(WITH_DSP_FFMPEG)
return freerdp_dsp_ffmpeg_encode(context, srcFormat, data, length, out); return freerdp_dsp_ffmpeg_encode(context, srcFormat, pdata, length, out);
#else #else
if (!context || !context->common.encoder || !srcFormat || !data || !out) if (!context || !context->common.encoder || !srcFormat || !pdata || !out)
return FALSE; return FALSE;
AUDIO_FORMAT format = *srcFormat; AUDIO_FORMAT format = *srcFormat;
const BYTE* resampleData = NULL; const BYTE* resampleData = NULL;
size_t resampleLength = 0; size_t resampleLength = 0;
if (!freerdp_dsp_channel_mix(context, data, length, srcFormat, &resampleData, &resampleLength)) if (!freerdp_dsp_channel_mix(context, pdata, length, srcFormat, &resampleData, &resampleLength))
return FALSE; return FALSE;
format.nChannels = context->common.format.nChannels; format.nChannels = context->common.format.nChannels;
const BYTE* data = NULL;
if (!freerdp_dsp_resample(context, resampleData, resampleLength, &format, &data, &length)) if (!freerdp_dsp_resample(context, resampleData, resampleLength, &format, &data, &length))
return FALSE; return FALSE;
@ -1435,10 +1437,12 @@ BOOL freerdp_dsp_supports_format(const AUDIO_FORMAT* WINPR_RESTRICT format, BOOL
#endif #endif
#if defined(WITH_OPUS) #if defined(WITH_OPUS)
/* fallthrough */
WINPR_FALLTHROUGH WINPR_FALLTHROUGH
case WAVE_FORMAT_OPUS: case WAVE_FORMAT_OPUS:
return opus_is_valid_samplerate(format); return opus_is_valid_samplerate(format);
#endif #endif
/* fallthrough */
WINPR_FALLTHROUGH WINPR_FALLTHROUGH
default: default:
return FALSE; return FALSE;

View File

@ -444,7 +444,7 @@ static INLINE void write_pixel_16(BYTE* _buf, UINT16 _pix)
#define RLEEXTRA #define RLEEXTRA
#undef ENSURE_CAPACITY #undef ENSURE_CAPACITY
#define ENSURE_CAPACITY(_start, _end, _size) ensure_capacity(_start, _end, _size, 1) #define ENSURE_CAPACITY(_start, _end, _size) ensure_capacity(_start, _end, _size, 1)
#include "include/bitmap.c" #include "include/bitmap.h"
#undef DESTWRITEPIXEL #undef DESTWRITEPIXEL
#undef DESTREADPIXEL #undef DESTREADPIXEL
@ -478,7 +478,7 @@ static INLINE void write_pixel_16(BYTE* _buf, UINT16 _pix)
#define RLEEXTRA #define RLEEXTRA
#undef ENSURE_CAPACITY #undef ENSURE_CAPACITY
#define ENSURE_CAPACITY(_start, _end, _size) ensure_capacity(_start, _end, _size, 2) #define ENSURE_CAPACITY(_start, _end, _size) ensure_capacity(_start, _end, _size, 2)
#include "include/bitmap.c" #include "include/bitmap.h"
#undef DESTWRITEPIXEL #undef DESTWRITEPIXEL
#undef DESTREADPIXEL #undef DESTREADPIXEL
@ -513,7 +513,7 @@ static INLINE void write_pixel_16(BYTE* _buf, UINT16 _pix)
#define RLEEXTRA #define RLEEXTRA
#undef ENSURE_CAPACITY #undef ENSURE_CAPACITY
#define ENSURE_CAPACITY(_start, _end, _size) ensure_capacity(_start, _end, _size, 3) #define ENSURE_CAPACITY(_start, _end, _size) ensure_capacity(_start, _end, _size, 3)
#include "include/bitmap.c" #include "include/bitmap.h"
struct S_BITMAP_INTERLEAVED_CONTEXT struct S_BITMAP_INTERLEAVED_CONTEXT
{ {

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

@ -1342,8 +1342,13 @@ BOOL freerdp_assistance_populate_settings_from_assistance_file(rdpAssistanceFile
if (ports != addresses) if (ports != addresses)
return FALSE; return FALSE;
const UINT32 port = (UINT32)ArrayList_GetItem(file->MachinePorts, 0); union
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, port)) {
UINT32 port;
void* data;
} cnv;
cnv.data = ArrayList_GetItem(file->MachinePorts, 0);
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, cnv.port))
return FALSE; return FALSE;
if (!freerdp_target_net_adresses_reset(settings, ports)) if (!freerdp_target_net_adresses_reset(settings, ports))
@ -1351,8 +1356,13 @@ BOOL freerdp_assistance_populate_settings_from_assistance_file(rdpAssistanceFile
for (size_t x = 0; x < ports; x++) for (size_t x = 0; x < ports; x++)
{ {
const UINT32 mport = (UINT32)ArrayList_GetItem(file->MachinePorts, x); union
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_TargetNetPorts, x, &mport)) {
UINT32 port;
void* data;
} cnv;
cnv.data = ArrayList_GetItem(file->MachinePorts, x);
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_TargetNetPorts, x, &cnv.port))
return FALSE; return FALSE;
} }
for (size_t i = 0; i < addresses; i++) for (size_t i = 0; i < addresses; i++)
@ -1451,7 +1461,15 @@ void freerdp_assistance_print_file(rdpAssistanceFile* file, wLog* log, DWORD lev
const char* uri = NULL; const char* uri = NULL;
const char* addr = ArrayList_GetItem(file->MachineAddresses, x); const char* addr = ArrayList_GetItem(file->MachineAddresses, x);
if (x < ArrayList_Count(file->MachinePorts)) if (x < ArrayList_Count(file->MachinePorts))
port = (UINT32)ArrayList_GetItem(file->MachinePorts, x); {
union
{
UINT32 port;
void* data;
} cnv;
cnv.data = ArrayList_GetItem(file->MachinePorts, x);
port = cnv.port;
}
if (x < ArrayList_Count(file->MachineUris)) if (x < ArrayList_Count(file->MachineUris))
uri = ArrayList_GetItem(file->MachineUris, x); uri = ArrayList_GetItem(file->MachineUris, x);

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); free(sspi_module);
return InitSecurityInterface_ptr(); return FALSE;
}
free(sspi_module);
return cnv.InitSecurityInterface_ptr();
} }
return InitSecurityInterfaceEx(0); return InitSecurityInterfaceEx(0);

View File

@ -718,12 +718,15 @@ const char* freerdp_get_version_string(void)
const char* freerdp_get_build_config(void) const char* freerdp_get_build_config(void)
{ {
WINPR_PRAGMA_DIAG_PUSH
WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS
static const char build_config[] = static const char build_config[] =
"Build configuration: " FREERDP_BUILD_CONFIG "\n" "Build configuration: " FREERDP_BUILD_CONFIG "\n"
"Build type: " FREERDP_BUILD_TYPE "\n" "Build type: " FREERDP_BUILD_TYPE "\n"
"CFLAGS: " FREERDP_CFLAGS "\n" "CFLAGS: " FREERDP_CFLAGS "\n"
"Compiler: " FREERDP_COMPILER_ID ", " FREERDP_COMPILER_VERSION "\n" "Compiler: " FREERDP_COMPILER_ID ", " FREERDP_COMPILER_VERSION "\n"
"Target architecture: " FREERDP_TARGET_ARCH "\n"; "Target architecture: " FREERDP_TARGET_ARCH "\n";
WINPR_PRAGMA_DIAG_POP
return build_config; return build_config;
} }

View File

@ -2852,9 +2852,14 @@ static void log_build_warn(rdpRdp* rdp, const char* what, const char* msg,
BOOL (*cmp)(wLog* log, const char* tok)) BOOL (*cmp)(wLog* log, const char* tok))
{ {
WINPR_ASSERT(rdp); WINPR_ASSERT(rdp);
WINPR_PRAGMA_DIAG_PUSH
WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS
size_t len = sizeof(FREERDP_BUILD_CONFIG); size_t len = sizeof(FREERDP_BUILD_CONFIG);
char* list = calloc(len, sizeof(char)); char* list = calloc(len, sizeof(char));
char* config = _strdup(FREERDP_BUILD_CONFIG); char* config = _strdup(FREERDP_BUILD_CONFIG);
WINPR_PRAGMA_DIAG_POP
if (config && list) if (config && list)
{ {
char* tok = strtok(config, " "); char* tok = strtok(config, " ");

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

@ -25,18 +25,9 @@
#include <stdlib.h> #include <stdlib.h>
#define min(a, b) \ #define min(a, b) (a) < (b) ? (a) : (b)
({ \
__typeof__(a) _a = (a); \
__typeof__(b) _b = (b); \
_a < _b ? _a : _b; \
})
#define container_of(ptr, type, member) \ #define container_of(ptr, type, member) (type*)((char*)(ptr)-offsetof(type, member))
({ \
__typeof__(((type*)0)->member)* __mptr = (ptr); \
(type*)((char*)__mptr - offsetof(type, member)); \
})
#define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a)[0]) #define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a)[0])

View File

@ -33,13 +33,13 @@
// C23 related macros // C23 related macros
#if defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) #if defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
#define WINPR_FALLTHROUGH [[fallthrough]]; #define WINPR_FALLTHROUGH (void)0; [[fallthrough]];
#elif defined(__clang__) #elif defined(__clang__)
#define WINPR_FALLTHROUGH __attribute__((fallthrough)); #define WINPR_FALLTHROUGH (void)0; __attribute__((fallthrough));
#elif defined(__GNUC__) && (__GNUC__ >= 7) #elif defined(__GNUC__) && (__GNUC__ >= 7)
#define WINPR_FALLTHROUGH __attribute__((fallthrough)); #define WINPR_FALLTHROUGH (void)0; __attribute__((fallthrough));
#else #else
#define WINPR_FALLTHROUGH #define WINPR_FALLTHROUGH (void)0;
#endif #endif
/* Set by CMake during configuration */ /* Set by CMake during configuration */

View File

@ -24,6 +24,10 @@
#if defined(__clang__) #if defined(__clang__)
#define WINPR_PRAGMA_DIAG_PUSH _Pragma("clang diagnostic push") #define WINPR_PRAGMA_DIAG_PUSH _Pragma("clang diagnostic push")
#define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS \
_Pragma("clang diagnostic ignored \"-Woverlength-strings\"")
#define WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS \
_Pragma("clang diagnostic ignored \"-Wdiscarded-qualifiers\"")
#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC _Pragma("clang diagnostic ignored \"-Wpedantic\"") #define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC _Pragma("clang diagnostic ignored \"-Wpedantic\"")
#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \ #define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \
_Pragma("clang diagnostic ignored \"-Wmissing-prototypes\"") _Pragma("clang diagnostic ignored \"-Wmissing-prototypes\"")
@ -43,6 +47,10 @@
#define WINPR_PRAGMA_UNROLL_LOOP _Pragma("clang loop vectorize_width(8) interleave_count(8)") #define WINPR_PRAGMA_UNROLL_LOOP _Pragma("clang loop vectorize_width(8) interleave_count(8)")
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define WINPR_PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push") #define WINPR_PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push")
#define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS \
_Pragma("GCC diagnostic ignored \"-Woverlength-strings\"")
#define WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS \
_Pragma("GCC diagnostic ignored \"-Wdiscarded-qualifiers\"")
#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC _Pragma("GCC diagnostic ignored \"-Wpedantic\"") #define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \ #define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \
_Pragma("GCC diagnostic ignored \"-Wmissing-prototypes\"") _Pragma("GCC diagnostic ignored \"-Wmissing-prototypes\"")
@ -64,6 +72,8 @@
#else #else
#define WINPR_PRAGMA_DIAG_PUSH #define WINPR_PRAGMA_DIAG_PUSH
#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC #define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC
#define WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS
#define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS
#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES #define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES
#define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES #define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO #define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO

View File

@ -446,7 +446,7 @@ WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit, WCHAR** context)
* http://msdn.microsoft.com/en-us/library/hh802935/ * http://msdn.microsoft.com/en-us/library/hh802935/
*/ */
#include "casing.c" #include "casing.h"
LPSTR CharUpperA(LPSTR lpsz) LPSTR CharUpperA(LPSTR lpsz)
{ {

View File

@ -235,9 +235,12 @@ BOOL winpr_HMAC_Init(WINPR_HMAC_CTX* ctx, WINPR_MD_TYPE md, const void* key, siz
if (!ctx->xhmac) if (!ctx->xhmac)
return FALSE; return FALSE;
WINPR_PRAGMA_DIAG_PUSH
WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS
const char* param_name = OSSL_MAC_PARAM_DIGEST; const char* param_name = OSSL_MAC_PARAM_DIGEST;
const OSSL_PARAM param[] = { OSSL_PARAM_construct_utf8_string(param_name, hash, 0), const OSSL_PARAM param[] = { OSSL_PARAM_construct_utf8_string(param_name, hash, 0),
OSSL_PARAM_construct_end() }; OSSL_PARAM_construct_end() };
WINPR_PRAGMA_DIAG_POP
if (EVP_MAC_init(ctx->xhmac, key, keylen, param) == 1) if (EVP_MAC_init(ctx->xhmac, key, keylen, param) == 1)
return TRUE; return TRUE;

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

@ -79,7 +79,7 @@
#define DEFINE_UNICODE FALSE #define DEFINE_UNICODE FALSE
#define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR
#define PATH_CCH_ADD_SEPARATOR PathCchAddBackslashA #define PATH_CCH_ADD_SEPARATOR PathCchAddBackslashA
#include "include/PathCchAddSeparator.c" #include "include/PathCchAddSeparator.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR #undef PATH_CCH_ADD_SEPARATOR
@ -87,7 +87,7 @@
#define DEFINE_UNICODE TRUE #define DEFINE_UNICODE TRUE
#define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR
#define PATH_CCH_ADD_SEPARATOR PathCchAddBackslashW #define PATH_CCH_ADD_SEPARATOR PathCchAddBackslashW
#include "include/PathCchAddSeparator.c" #include "include/PathCchAddSeparator.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR #undef PATH_CCH_ADD_SEPARATOR
@ -97,7 +97,7 @@
#define DEFINE_UNICODE FALSE #define DEFINE_UNICODE FALSE
#define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR
#define PATH_CCH_ADD_SEPARATOR PathCchAddSlashA #define PATH_CCH_ADD_SEPARATOR PathCchAddSlashA
#include "include/PathCchAddSeparator.c" #include "include/PathCchAddSeparator.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR #undef PATH_CCH_ADD_SEPARATOR
@ -105,7 +105,7 @@
#define DEFINE_UNICODE TRUE #define DEFINE_UNICODE TRUE
#define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR
#define PATH_CCH_ADD_SEPARATOR PathCchAddSlashW #define PATH_CCH_ADD_SEPARATOR PathCchAddSlashW
#include "include/PathCchAddSeparator.c" #include "include/PathCchAddSeparator.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR #undef PATH_CCH_ADD_SEPARATOR
@ -115,7 +115,7 @@
#define DEFINE_UNICODE FALSE #define DEFINE_UNICODE FALSE
#define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR
#define PATH_CCH_ADD_SEPARATOR PathCchAddSeparatorA #define PATH_CCH_ADD_SEPARATOR PathCchAddSeparatorA
#include "include/PathCchAddSeparator.c" #include "include/PathCchAddSeparator.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR #undef PATH_CCH_ADD_SEPARATOR
@ -123,7 +123,7 @@
#define DEFINE_UNICODE TRUE #define DEFINE_UNICODE TRUE
#define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR
#define PATH_CCH_ADD_SEPARATOR PathCchAddSeparatorW #define PATH_CCH_ADD_SEPARATOR PathCchAddSeparatorW
#include "include/PathCchAddSeparator.c" #include "include/PathCchAddSeparator.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR #undef PATH_CCH_ADD_SEPARATOR
@ -153,7 +153,7 @@ HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath)
#define DEFINE_UNICODE FALSE #define DEFINE_UNICODE FALSE
#define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddBackslashExA #define PATH_CCH_ADD_SEPARATOR_EX PathCchAddBackslashExA
#include "include/PathCchAddSeparatorEx.c" #include "include/PathCchAddSeparatorEx.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR_EX #undef PATH_CCH_ADD_SEPARATOR_EX
@ -161,7 +161,7 @@ HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath)
#define DEFINE_UNICODE TRUE #define DEFINE_UNICODE TRUE
#define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddBackslashExW #define PATH_CCH_ADD_SEPARATOR_EX PathCchAddBackslashExW
#include "include/PathCchAddSeparatorEx.c" #include "include/PathCchAddSeparatorEx.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR_EX #undef PATH_CCH_ADD_SEPARATOR_EX
@ -171,7 +171,7 @@ HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath)
#define DEFINE_UNICODE FALSE #define DEFINE_UNICODE FALSE
#define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddSlashExA #define PATH_CCH_ADD_SEPARATOR_EX PathCchAddSlashExA
#include "include/PathCchAddSeparatorEx.c" #include "include/PathCchAddSeparatorEx.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR_EX #undef PATH_CCH_ADD_SEPARATOR_EX
@ -179,7 +179,7 @@ HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath)
#define DEFINE_UNICODE TRUE #define DEFINE_UNICODE TRUE
#define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddSlashExW #define PATH_CCH_ADD_SEPARATOR_EX PathCchAddSlashExW
#include "include/PathCchAddSeparatorEx.c" #include "include/PathCchAddSeparatorEx.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR_EX #undef PATH_CCH_ADD_SEPARATOR_EX
@ -189,7 +189,7 @@ HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath)
#define DEFINE_UNICODE FALSE #define DEFINE_UNICODE FALSE
#define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddSeparatorExA #define PATH_CCH_ADD_SEPARATOR_EX PathCchAddSeparatorExA
#include "include/PathCchAddSeparatorEx.c" #include "include/PathCchAddSeparatorEx.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR_EX #undef PATH_CCH_ADD_SEPARATOR_EX
@ -197,7 +197,7 @@ HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath)
#define DEFINE_UNICODE TRUE #define DEFINE_UNICODE TRUE
#define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddSeparatorExW #define PATH_CCH_ADD_SEPARATOR_EX PathCchAddSeparatorExW
#include "include/PathCchAddSeparatorEx.c" #include "include/PathCchAddSeparatorEx.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR_EX #undef PATH_CCH_ADD_SEPARATOR_EX
@ -225,7 +225,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define DEFINE_UNICODE FALSE #define DEFINE_UNICODE FALSE
#define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR
#define PATH_CCH_ADD_EXTENSION PathCchAddExtensionA #define PATH_CCH_ADD_EXTENSION PathCchAddExtensionA
#include "include/PathCchAddExtension.c" #include "include/PathCchAddExtension.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_EXTENSION #undef PATH_CCH_ADD_EXTENSION
@ -233,7 +233,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define DEFINE_UNICODE TRUE #define DEFINE_UNICODE TRUE
#define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR
#define PATH_CCH_ADD_EXTENSION PathCchAddExtensionW #define PATH_CCH_ADD_EXTENSION PathCchAddExtensionW
#include "include/PathCchAddExtension.c" #include "include/PathCchAddExtension.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_EXTENSION #undef PATH_CCH_ADD_EXTENSION
@ -243,7 +243,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define DEFINE_UNICODE FALSE #define DEFINE_UNICODE FALSE
#define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR
#define PATH_CCH_ADD_EXTENSION UnixPathCchAddExtensionA #define PATH_CCH_ADD_EXTENSION UnixPathCchAddExtensionA
#include "include/PathCchAddExtension.c" #include "include/PathCchAddExtension.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_EXTENSION #undef PATH_CCH_ADD_EXTENSION
@ -251,7 +251,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define DEFINE_UNICODE TRUE #define DEFINE_UNICODE TRUE
#define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR
#define PATH_CCH_ADD_EXTENSION UnixPathCchAddExtensionW #define PATH_CCH_ADD_EXTENSION UnixPathCchAddExtensionW
#include "include/PathCchAddExtension.c" #include "include/PathCchAddExtension.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_EXTENSION #undef PATH_CCH_ADD_EXTENSION
@ -261,7 +261,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define DEFINE_UNICODE FALSE #define DEFINE_UNICODE FALSE
#define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR
#define PATH_CCH_ADD_EXTENSION NativePathCchAddExtensionA #define PATH_CCH_ADD_EXTENSION NativePathCchAddExtensionA
#include "include/PathCchAddExtension.c" #include "include/PathCchAddExtension.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_EXTENSION #undef PATH_CCH_ADD_EXTENSION
@ -269,7 +269,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define DEFINE_UNICODE TRUE #define DEFINE_UNICODE TRUE
#define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR
#define PATH_CCH_ADD_EXTENSION NativePathCchAddExtensionW #define PATH_CCH_ADD_EXTENSION NativePathCchAddExtensionW
#include "include/PathCchAddExtension.c" #include "include/PathCchAddExtension.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_EXTENSION #undef PATH_CCH_ADD_EXTENSION
@ -284,7 +284,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR
#define CUR_PATH_SEPARATOR_STR PATH_BACKSLASH_STR #define CUR_PATH_SEPARATOR_STR PATH_BACKSLASH_STR
#define PATH_CCH_APPEND PathCchAppendA #define PATH_CCH_APPEND PathCchAppendA
#include "include/PathCchAppend.c" #include "include/PathCchAppend.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -294,7 +294,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR
#define CUR_PATH_SEPARATOR_STR PATH_BACKSLASH_STR_W #define CUR_PATH_SEPARATOR_STR PATH_BACKSLASH_STR_W
#define PATH_CCH_APPEND PathCchAppendW #define PATH_CCH_APPEND PathCchAppendW
#include "include/PathCchAppend.c" #include "include/PathCchAppend.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -306,7 +306,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR
#define CUR_PATH_SEPARATOR_STR PATH_SLASH_STR #define CUR_PATH_SEPARATOR_STR PATH_SLASH_STR
#define PATH_CCH_APPEND UnixPathCchAppendA #define PATH_CCH_APPEND UnixPathCchAppendA
#include "include/PathCchAppend.c" #include "include/PathCchAppend.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -316,7 +316,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR
#define CUR_PATH_SEPARATOR_STR PATH_SLASH_STR_W #define CUR_PATH_SEPARATOR_STR PATH_SLASH_STR_W
#define PATH_CCH_APPEND UnixPathCchAppendW #define PATH_CCH_APPEND UnixPathCchAppendW
#include "include/PathCchAppend.c" #include "include/PathCchAppend.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -328,7 +328,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR
#define CUR_PATH_SEPARATOR_STR PATH_SEPARATOR_STR #define CUR_PATH_SEPARATOR_STR PATH_SEPARATOR_STR
#define PATH_CCH_APPEND NativePathCchAppendA #define PATH_CCH_APPEND NativePathCchAppendA
#include "include/PathCchAppend.c" #include "include/PathCchAppend.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -338,7 +338,7 @@ HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
#define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR
#define CUR_PATH_SEPARATOR_STR PATH_SEPARATOR_STR_W #define CUR_PATH_SEPARATOR_STR PATH_SEPARATOR_STR_W
#define PATH_CCH_APPEND NativePathCchAppendW #define PATH_CCH_APPEND NativePathCchAppendW
#include "include/PathCchAppend.c" #include "include/PathCchAppend.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -454,7 +454,7 @@ HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn,
#define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR
#define CUR_PATH_SEPARATOR_STR PATH_BACKSLASH_STR #define CUR_PATH_SEPARATOR_STR PATH_BACKSLASH_STR
#define PATH_ALLOC_COMBINE PathAllocCombineA #define PATH_ALLOC_COMBINE PathAllocCombineA
#include "include/PathAllocCombine.c" #include "include/PathAllocCombine.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -464,7 +464,7 @@ HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn,
#define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_BACKSLASH_CHR
#define CUR_PATH_SEPARATOR_STR PATH_BACKSLASH_STR_W #define CUR_PATH_SEPARATOR_STR PATH_BACKSLASH_STR_W
#define PATH_ALLOC_COMBINE PathAllocCombineW #define PATH_ALLOC_COMBINE PathAllocCombineW
#include "include/PathAllocCombine.c" #include "include/PathAllocCombine.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -476,7 +476,7 @@ HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn,
#define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR
#define CUR_PATH_SEPARATOR_STR PATH_SLASH_STR #define CUR_PATH_SEPARATOR_STR PATH_SLASH_STR
#define PATH_ALLOC_COMBINE UnixPathAllocCombineA #define PATH_ALLOC_COMBINE UnixPathAllocCombineA
#include "include/PathAllocCombine.c" #include "include/PathAllocCombine.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -486,7 +486,7 @@ HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn,
#define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SLASH_CHR
#define CUR_PATH_SEPARATOR_STR PATH_SLASH_STR_W #define CUR_PATH_SEPARATOR_STR PATH_SLASH_STR_W
#define PATH_ALLOC_COMBINE UnixPathAllocCombineW #define PATH_ALLOC_COMBINE UnixPathAllocCombineW
#include "include/PathAllocCombine.c" #include "include/PathAllocCombine.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -498,7 +498,7 @@ HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn,
#define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR
#define CUR_PATH_SEPARATOR_STR PATH_SEPARATOR_STR #define CUR_PATH_SEPARATOR_STR PATH_SEPARATOR_STR
#define PATH_ALLOC_COMBINE NativePathAllocCombineA #define PATH_ALLOC_COMBINE NativePathAllocCombineA
#include "include/PathAllocCombine.c" #include "include/PathAllocCombine.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR
@ -508,7 +508,7 @@ HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn,
#define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR #define CUR_PATH_SEPARATOR_CHR PATH_SEPARATOR_CHR
#define CUR_PATH_SEPARATOR_STR PATH_SEPARATOR_STR_W #define CUR_PATH_SEPARATOR_STR PATH_SEPARATOR_STR_W
#define PATH_ALLOC_COMBINE NativePathAllocCombineW #define PATH_ALLOC_COMBINE NativePathAllocCombineW
#include "include/PathAllocCombine.c" #include "include/PathAllocCombine.h"
#undef DEFINE_UNICODE #undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR #undef CUR_PATH_SEPARATOR_CHR
#undef CUR_PATH_SEPARATOR_STR #undef CUR_PATH_SEPARATOR_STR

View File

@ -875,7 +875,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextA(
goto bad_token; goto bad_token;
/* Continue to AP-REQ */ /* Continue to AP-REQ */
/* fall through */ /* fallthrough */
WINPR_FALLTHROUGH WINPR_FALLTHROUGH
case KERBEROS_STATE_AP_REQ: case KERBEROS_STATE_AP_REQ:

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

@ -20,7 +20,7 @@
#include <winpr/config.h> #include <winpr/config.h>
#define __STDC_WANT_LIB_EXT1__ 1 // NOLINT(bugprone-reserved-identifier) #define __STDC_WANT_LIB_EXT1__ 1 // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>

View File

@ -36,10 +36,20 @@
#define TAG WINPR_TAG("utils.unwind") #define TAG WINPR_TAG("utils.unwind")
#define UNWIND_MAX_LINE_SIZE 1024ULL
typedef struct typedef struct
{ {
uintptr_t pc; union
void* langSpecificData; {
uintptr_t uw;
void* pv;
} pc;
union
{
uintptr_t uptr;
void* pv;
} langSpecificData;
} unwind_info_t; } unwind_info_t;
typedef struct typedef struct
@ -103,8 +113,13 @@ static _Unwind_Reason_Code unwind_backtrace_callback(struct _Unwind_Context* con
if (ctx->pos < ctx->size) if (ctx->pos < ctx->size)
{ {
unwind_info_t* info = &ctx->info[ctx->pos++]; unwind_info_t* info = &ctx->info[ctx->pos++];
info->pc = _Unwind_GetIP(context); info->pc.uw = _Unwind_GetIP(context);
info->langSpecificData = _Unwind_GetLanguageSpecificData(context);
/* _Unwind_GetLanguageSpecificData has various return value definitions,
* cast to the type we expect and disable linter warnings
*/
// NOLINTNEXTLINE(google-readability-casting,readability-redundant-casting)
info->langSpecificData.pv = (void*)_Unwind_GetLanguageSpecificData(context);
} }
return _URC_NO_REASON; return _URC_NO_REASON;
@ -145,8 +160,6 @@ void winpr_unwind_backtrace_free(void* buffer)
free(ctx); free(ctx);
} }
#define UNWIND_MAX_LINE_SIZE 1024
char** winpr_unwind_backtrace_symbols(void* buffer, size_t* used) char** winpr_unwind_backtrace_symbols(void* buffer, size_t* used)
{ {
union union
@ -172,12 +185,12 @@ char** winpr_unwind_backtrace_symbols(void* buffer, size_t* used)
char* msg = cnv.cp + ctx->pos * sizeof(char*) + x * UNWIND_MAX_LINE_SIZE; char* msg = cnv.cp + ctx->pos * sizeof(char*) + x * UNWIND_MAX_LINE_SIZE;
const unwind_info_t* info = &ctx->info[x]; const unwind_info_t* info = &ctx->info[x];
Dl_info dlinfo = { 0 }; Dl_info dlinfo = { 0 };
int rc = dladdr((void*)info->pc, &dlinfo); int rc = dladdr(info->pc.pv, &dlinfo);
cnv.cpp[x] = msg; cnv.cpp[x] = msg;
if (rc == 0) if (rc == 0)
(void)_snprintf(msg, UNWIND_MAX_LINE_SIZE, "unresolvable, address=%p", (void*)info->pc); (void)_snprintf(msg, UNWIND_MAX_LINE_SIZE, "unresolvable, address=%p", info->pc.pv);
else else
(void)_snprintf(msg, UNWIND_MAX_LINE_SIZE, "dli_fname=%s [%p], dli_sname=%s [%p]", (void)_snprintf(msg, UNWIND_MAX_LINE_SIZE, "dli_fname=%s [%p], dli_sname=%s [%p]",
dlinfo.dli_fname, dlinfo.dli_fbase, dlinfo.dli_sname, dlinfo.dli_saddr); dlinfo.dli_fname, dlinfo.dli_fbase, dlinfo.dli_sname, dlinfo.dli_saddr);

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;
} }