Merge pull request #12415 from akallabeth/compile-issues

Address some GCC compile issues
This commit is contained in:
akallabeth
2026-03-03 17:49:58 +01:00
committed by GitHub
14 changed files with 111 additions and 104 deletions

View File

@@ -456,9 +456,9 @@ static void check_open_close_receive(DVCMAN_CHANNEL* channel)
WINPR_ASSERT(cb);
if (!cb->OnOpen || !cb->OnClose || !cb->OnDataReceived)
WLog_VRB(TAG, "{%s:%" PRIu32 "} OnOpen=%p, OnClose=%p, OnDataReceived=%p", name, id,
WINPR_CXX_COMPAT_CAST(const void*, cb->OnOpen),
WINPR_CXX_COMPAT_CAST(const void*, cb->OnClose),
WINPR_CXX_COMPAT_CAST(const void*, cb->OnDataReceived));
WINPR_FUNC_PTR_CAST(cb->OnOpen, const void*),
WINPR_FUNC_PTR_CAST(cb->OnClose, const void*),
WINPR_FUNC_PTR_CAST(cb->OnDataReceived, const void*));
}
static UINT dvcman_call_on_receive(DVCMAN_CHANNEL* channel, wStream* data)

View File

@@ -1021,24 +1021,22 @@ BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file, const char* name, rdp_file_
return FALSE;
}
(void)_fseeki64(fp, 0, SEEK_END);
if (_fseeki64(fp, 0, SEEK_END) < 0)
goto fail;
file_size = _ftelli64(fp);
(void)_fseeki64(fp, 0, SEEK_SET);
if (_fseeki64(fp, 0, SEEK_SET) < 0)
goto fail;
if (file_size < 1)
{
WLog_ERR(TAG, "RDP file %s is empty", name);
(void)fclose(fp);
return FALSE;
goto fail;
}
buffer = (BYTE*)malloc((size_t)file_size + 2);
if (!buffer)
{
(void)fclose(fp);
return FALSE;
}
goto fail;
read_size = fread(buffer, (size_t)file_size, 1, fp);
@@ -1048,18 +1046,18 @@ BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file, const char* name, rdp_file_
read_size = (size_t)file_size;
}
(void)fclose(fp);
if (read_size < 1)
{
WLog_ERR(TAG, "Could not read from RDP file %s", name);
free(buffer);
return FALSE;
goto fail;
}
buffer[file_size] = '\0';
buffer[file_size + 1] = '\0';
status = freerdp_client_parse_rdp_file_buffer_ex(file, buffer, (size_t)file_size, parse);
fail:
(void)fclose(fp);
free(buffer);
return status;
}

View File

@@ -220,11 +220,10 @@ extern "C"
* a certificate only for this session, 0 otherwise.
*/
#if defined(WITH_FREERDP_DEPRECATED)
typedef WINPR_DEPRECATED_VAR(
"Use pVerifyCertificateEx",
DWORD (*pVerifyCertificate)(freerdp* instance, const char* common_name, const char* subject,
const char* issuer, const char* fingerprint,
BOOL host_mismatch));
WINPR_DEPRECATED_VAR("Use pVerifyCertificateEx",
typedef DWORD (*pVerifyCertificate)(
freerdp* instance, const char* common_name, const char* subject,
const char* issuer, const char* fingerprint, BOOL host_mismatch));
#endif
/** @brief Callback used if user interaction is required to accept
@@ -262,12 +261,12 @@ extern "C"
* a certificate only for this session, 0 otherwise.
*/
#if defined(WITH_FREERDP_DEPRECATED)
typedef WINPR_DEPRECATED_VAR(
"Use pVerifyChangedCertificateEx",
DWORD (*pVerifyChangedCertificate)(freerdp* instance, const char* common_name,
const char* subject, const char* issuer,
const char* new_fingerprint, const char* old_subject,
const char* old_issuer, const char* old_fingerprint));
WINPR_DEPRECATED_VAR("Use pVerifyChangedCertificateEx",
typedef DWORD (*pVerifyChangedCertificate)(
freerdp* instance, const char* common_name, const char* subject,
const char* issuer, const char* new_fingerprint,
const char* old_subject, const char* old_issuer,
const char* old_fingerprint));
#endif
/** @brief Callback used if user interaction is required to accept

View File

@@ -239,9 +239,8 @@ extern "C"
FREERDP_API ADDIN_ARGV* freerdp_static_channel_collection_find(rdpSettings* settings,
const char* name);
#if defined(WITH_FREERDP_DEPRECATED)
WINPR_DEPRECATED(
WINPR_ATTR_NODISCARD FREERDP_API ADDIN_ARGV* WINPR_ATTR_MALLOC(freerdp_addin_argv_free, 1)
WINPR_ATTR_NODISCARD freerdp_static_channel_clone(ADDIN_ARGV* channel));
WINPR_DEPRECATED(WINPR_ATTR_MALLOC(freerdp_addin_argv_free, 1)
FREERDP_API ADDIN_ARGV* freerdp_static_channel_clone(ADDIN_ARGV* channel));
#endif
FREERDP_API void freerdp_static_channel_collection_free(rdpSettings* settings);
@@ -259,8 +258,8 @@ extern "C"
#if defined(WITH_FREERDP_DEPRECATED)
WINPR_DEPRECATED(
WINPR_ATTR_NODISCARD FREERDP_API ADDIN_ARGV* WINPR_ATTR_MALLOC(freerdp_addin_argv_free, 1)
WINPR_ATTR_NODISCARD freerdp_dynamic_channel_clone(ADDIN_ARGV* channel));
WINPR_ATTR_MALLOC(freerdp_addin_argv_free, 1)
FREERDP_API ADDIN_ARGV* freerdp_dynamic_channel_clone(ADDIN_ARGV* channel));
#endif
FREERDP_API void freerdp_dynamic_channel_collection_free(rdpSettings* settings);

View File

@@ -1225,9 +1225,8 @@ int freerdp_assistance_parse_file_buffer(rdpAssistanceFile* file, const char* cb
int freerdp_assistance_parse_file(rdpAssistanceFile* file, const char* name, const char* password)
{
int status = 0;
int status = -1;
BYTE* buffer = nullptr;
FILE* fp = nullptr;
size_t readSize = 0;
union
{
@@ -1238,7 +1237,7 @@ int freerdp_assistance_parse_file(rdpAssistanceFile* file, const char* name, con
if (!update_name(file, name))
return -1;
fp = winpr_fopen(name, "r");
FILE* fp = winpr_fopen(name, "r");
if (!fp)
{
@@ -1246,24 +1245,22 @@ int freerdp_assistance_parse_file(rdpAssistanceFile* file, const char* name, con
return -1;
}
(void)_fseeki64(fp, 0, SEEK_END);
if (_fseeki64(fp, 0, SEEK_END) < 0)
goto fail;
fileSize.i64 = _ftelli64(fp);
(void)_fseeki64(fp, 0, SEEK_SET);
if (_fseeki64(fp, 0, SEEK_SET) < 0)
goto fail;
if (fileSize.i64 < 1)
{
WLog_ERR(TAG, "Failed to read ASSISTANCE file %s ", name);
(void)fclose(fp);
return -1;
goto fail;
}
buffer = (BYTE*)malloc(fileSize.s + 2);
if (!buffer)
{
(void)fclose(fp);
return -1;
}
goto fail;
readSize = fread(buffer, fileSize.s, 1, fp);
@@ -1273,19 +1270,18 @@ int freerdp_assistance_parse_file(rdpAssistanceFile* file, const char* name, con
readSize = fileSize.s;
}
(void)fclose(fp);
if (readSize < 1)
{
WLog_ERR(TAG, "Failed to read ASSISTANCE file %s ", name);
free(buffer);
buffer = nullptr;
return -1;
goto fail;
}
buffer[fileSize.s] = '\0';
buffer[fileSize.s + 1] = '\0';
status = freerdp_assistance_parse_file_buffer(file, (char*)buffer, fileSize.s, password);
fail:
(void)fclose(fp);
free(buffer);
return status;
}

View File

@@ -851,8 +851,8 @@ BOOL freerdp_client_channel_register(rdpChannels* channels, HANDLE handle,
if (!channels || (handle == INVALID_HANDLE_VALUE) || !fkt)
{
WLog_ERR(TAG, "Invalid function arguments (channels=%p, handle=%p, fkt=%p, userdata=%p",
WINPR_CXX_COMPAT_CAST(const void*, channels), handle,
WINPR_CXX_COMPAT_CAST(const void*, fkt), userdata);
WINPR_FUNC_PTR_CAST(channels, const void*), handle,
WINPR_FUNC_PTR_CAST(fkt, const void*), userdata);
return FALSE;
}

View File

@@ -85,7 +85,8 @@ state_run_t multitransport_recv_request(rdpMultitransport* multi, wStream* s)
WLog_WARN(TAG,
"reserved is %" PRIu16 " instead of 0, skipping %" PRIuz "bytes of unknown data",
reserved, Stream_GetRemainingLength(s));
(void)Stream_SafeSeek(s, Stream_GetRemainingLength(s));
if (!Stream_SafeSeek(s, Stream_GetRemainingLength(s)))
return STATE_RUN_FAILED;
}
WINPR_ASSERT(multi->MtRequest);

View File

@@ -1656,8 +1656,10 @@ BOOL WINAPI FreeRDP_WTSVirtualChannelRead(HANDLE hChannelHandle, WINPR_ATTR_UNUS
if (messageCtx->offset >= messageCtx->length)
{
(void)MessageQueue_Peek(channel->queue, &message, TRUE);
const int rc = MessageQueue_Peek(channel->queue, &message, TRUE);
peer_channel_queue_free_message(&message);
if (rc < 0)
return FALSE;
}
return TRUE;

View File

@@ -58,8 +58,8 @@ static void delete_file(char* path)
int rs = _fseeki64(fp, 0, SEEK_END);
if (rs == 0)
size = _ftelli64(fp);
(void)_fseeki64(fp, 0, SEEK_SET);
if (_fseeki64(fp, 0, SEEK_SET) == 0)
{
for (INT64 x = 0; x < size; x += sizeof(buffer))
{
const size_t dnmemb = (size_t)(size - x);
@@ -68,6 +68,7 @@ static void delete_file(char* path)
if (count != 1)
break;
}
}
(void)fclose(fp);
}

View File

@@ -79,7 +79,10 @@ static
return FALSE;
if (pOffset)
(void)_fseeki64(fp, WINPR_ASSERTING_INT_CAST(int64_t, *pOffset), SEEK_SET);
{
if (_fseeki64(fp, WINPR_ASSERTING_INT_CAST(int64_t, *pOffset), SEEK_SET) < 0)
goto fail;
}
r = fread(&ts, 1, sizeof(ts), fp);
if (r != sizeof(ts))

View File

@@ -49,10 +49,9 @@ static const SCardApiFunctionTable* g_SCardApi = nullptr;
return SCARD_E_NO_SERVICE; \
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
{ \
WLog_DBG( \
TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi), \
WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi ? g_SCardApi->pfn##_name : nullptr)); \
WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
WINPR_FUNC_PTR_CAST(g_SCardApi, const void*), \
WINPR_FUNC_PTR_CAST(g_SCardApi ? g_SCardApi->pfn##_name : nullptr, const void*)); \
return SCARD_E_NO_SERVICE; \
} \
return g_SCardApi->pfn##_name(__VA_ARGS__)
@@ -62,10 +61,9 @@ static const SCardApiFunctionTable* g_SCardApi = nullptr;
return nullptr; \
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
{ \
WLog_DBG( \
TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi), \
WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi ? g_SCardApi->pfn##_name : nullptr)); \
WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
WINPR_FUNC_PTR_CAST(g_SCardApi, const void*), \
WINPR_FUNC_PTR_CAST(g_SCardApi ? g_SCardApi->pfn##_name : nullptr, const void*)); \
return nullptr; \
} \
return g_SCardApi->pfn##_name()
@@ -75,10 +73,9 @@ static const SCardApiFunctionTable* g_SCardApi = nullptr;
return; \
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
{ \
WLog_DBG( \
TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi), \
WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi ? g_SCardApi->pfn##_name : nullptr)); \
WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
WINPR_FUNC_PTR_CAST(g_SCardApi, const void*), \
WINPR_FUNC_PTR_CAST(g_SCardApi ? g_SCardApi->pfn##_name : nullptr, const void*)); \
return; \
} \
g_SCardApi->pfn##_name()

View File

@@ -263,7 +263,10 @@ int MessageQueue_Peek(wMessageQueue* queue, wMessage* message, BOOL remove)
queue->size--;
if (queue->size < 1)
(void)ResetEvent(queue->event);
{
if (ResetEvent(queue->event))
status = -1;
}
}
}
@@ -346,7 +349,8 @@ int MessageQueue_Clear(wMessageQueue* queue)
queue->head = (queue->head + 1) % queue->capacity;
queue->size--;
}
(void)ResetEvent(queue->event);
if (!ResetEvent(queue->event))
status = -1;
queue->closed = FALSE;
LeaveCriticalSection(&queue->lock);

View File

@@ -278,7 +278,10 @@ BOOL Queue_Enqueue(wQueue* queue, const void* obj)
queue->size++;
if (signalSet)
(void)SetEvent(queue->event);
{
if (!SetEvent(queue->event))
goto out;
}
}
out:

View File

@@ -95,14 +95,18 @@ static BOOL WLog_UdpAppender_WriteMessage(wLog* log, wLogAppender* appender,
char prefix[WLOG_MAX_PREFIX_SIZE] = WINPR_C_ARRAY_INIT;
WLog_Layout_GetMessagePrefix(log, appender->Layout, cmessage, prefix, sizeof(prefix));
(void)_sendto(udpAppender->sock, prefix, (int)strnlen(prefix, ARRAYSIZE(prefix)), 0,
&udpAppender->targetAddr, udpAppender->targetAddrLen);
(void)_sendto(udpAppender->sock, cmessage->TextString,
BOOL res = TRUE;
if (_sendto(udpAppender->sock, prefix, (int)strnlen(prefix, ARRAYSIZE(prefix)), 0,
&udpAppender->targetAddr, udpAppender->targetAddrLen) < 0)
res = FALSE;
if (_sendto(udpAppender->sock, cmessage->TextString,
(int)strnlen(cmessage->TextString, INT_MAX), 0, &udpAppender->targetAddr,
udpAppender->targetAddrLen);
(void)_sendto(udpAppender->sock, "\n", 1, 0, &udpAppender->targetAddr,
udpAppender->targetAddrLen);
return TRUE;
udpAppender->targetAddrLen) < 0)
res = FALSE;
if (_sendto(udpAppender->sock, "\n", 1, 0, &udpAppender->targetAddr,
udpAppender->targetAddrLen) < 0)
res = FALSE;
return res;
}
static BOOL WLog_UdpAppender_WriteDataMessage(wLog* log, wLogAppender* appender,