From 74530a793143dec2b98dd961f596e3f9c3f9be6e Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 24 Jan 2023 14:37:41 +0100 Subject: [PATCH] [format strings] ensure __LINE__ is of type size_t __LINE__ is not particularily well defined (most fall back to int). We want to ensure that all the uses in a format string match the format specifier, so do an explicit cast --- libfreerdp/core/activation.c | 2 +- libfreerdp/core/license.c | 2 +- server/proxy/channels/pf_channel_rdpdr.c | 4 ++-- winpr/include/winpr/assert.h | 2 +- winpr/libwinpr/sspi/NTLM/ntlm_compute.c | 4 ++-- winpr/libwinpr/sspi/NTLM/ntlm_message.c | 4 ++-- winpr/libwinpr/utils/stream.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libfreerdp/core/activation.c b/libfreerdp/core/activation.c index 6b8c26ec6..e2908fd91 100644 --- a/libfreerdp/core/activation.c +++ b/libfreerdp/core/activation.c @@ -47,7 +47,7 @@ static BOOL rdp_recv_sync_pdu(rdpRdp* rdp, wStream* s, const char* what) WINPR_UNUSED(rdp); if (!Stream_CheckAndLogRequiredLengthEx(TAG, WLOG_WARN, s, 4, "%s(%s:%" PRIuz ") %s", - __FUNCTION__, __FILE__, __LINE__, what)) + __FUNCTION__, __FILE__, (size_t)__LINE__, what)) return FALSE; Stream_Read_UINT16(s, msgType); if (msgType != SYNCMSGTYPE_SYNC) diff --git a/libfreerdp/core/license.c b/libfreerdp/core/license.c index a44797521..f6f81819b 100644 --- a/libfreerdp/core/license.c +++ b/libfreerdp/core/license.c @@ -464,7 +464,7 @@ static BOOL license_check_stream_capacity(wStream* s, size_t expect, const char* WINPR_ASSERT(where); if (!Stream_CheckAndLogRequiredCapacityEx(TAG, WLOG_WARN, s, expect, 1, "%s(%s:%" PRIuz ") %s", - __FUNCTION__, __FILE__, __LINE__, where)) + __FUNCTION__, __FILE__, (size_t)__LINE__, where)) return FALSE; return TRUE; diff --git a/server/proxy/channels/pf_channel_rdpdr.c b/server/proxy/channels/pf_channel_rdpdr.c index 92898f7ce..519219cbc 100644 --- a/server/proxy/channels/pf_channel_rdpdr.c +++ b/server/proxy/channels/pf_channel_rdpdr.c @@ -135,11 +135,11 @@ typedef struct #define Stream_CheckAndLogRequiredLengthSrv(log, s, len) \ Stream_CheckAndLogRequiredLengthWLogEx(log, WLOG_WARN, s, len, \ proxy_client_rx " %s(%s:%" PRIuz ")", __FUNCTION__, \ - __FILE__, __LINE__) + __FILE__, (size_t)__LINE__) #define Stream_CheckAndLogRequiredLengthClient(log, s, len) \ Stream_CheckAndLogRequiredLengthWLogEx(log, WLOG_WARN, s, len, \ proxy_server_rx " %s(%s:%" PRIuz ")", __FUNCTION__, \ - __FILE__, __LINE__) + __FILE__, (size_t)__LINE__) #define Stream_CheckAndLogRequiredLengthRx(srv, log, s, len) \ Stream_CheckAndLogRequiredLengthRx_(srv, log, s, len, __FUNCTION__, __FILE__, __LINE__) static BOOL Stream_CheckAndLogRequiredLengthRx_(BOOL srv, wLog* log, wStream* s, size_t len, diff --git a/winpr/include/winpr/assert.h b/winpr/include/winpr/assert.h index 4c987573c..86adc2468 100644 --- a/winpr/include/winpr/assert.h +++ b/winpr/include/winpr/assert.h @@ -35,7 +35,7 @@ { \ wLog* _log_cached_ptr = WLog_Get("com.freerdp.winpr.assert"); \ WLog_Print(_log_cached_ptr, WLOG_FATAL, "%s [%s:%s:%" PRIuz "]", #cond, __FILE__, \ - __FUNCTION__, __LINE__); \ + __FUNCTION__, (size_t)__LINE__); \ winpr_log_backtrace_ex(_log_cached_ptr, WLOG_FATAL, 20); \ abort(); \ } \ diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_compute.c b/winpr/libwinpr/sspi/NTLM/ntlm_compute.c index 66d41b43e..29bb00050 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_compute.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_compute.c @@ -38,7 +38,7 @@ #define NTLM_CheckAndLogRequiredCapacity(tag, s, nmemb, what) \ Stream_CheckAndLogRequiredCapacityEx(tag, WLOG_WARN, s, nmemb, 1, "%s(%s:%" PRIuz ") " what, \ - __FUNCTION__, __FILE__, __LINE__) + __FUNCTION__, __FILE__, (size_t)__LINE__) static char NTLM_CLIENT_SIGN_MAGIC[] = "session key to client-to-server signing key magic constant"; static char NTLM_SERVER_SIGN_MAGIC[] = "session key to server-to-client signing key magic constant"; @@ -111,7 +111,7 @@ BOOL ntlm_write_version_info(wStream* s, const NTLM_VERSION_INFO* versionInfo) if (!Stream_CheckAndLogRequiredCapacityEx( TAG, WLOG_WARN, s, 5ull + sizeof(versionInfo->Reserved), 1ull, - "%s(%s:%" PRIuz ") NTLM_VERSION_INFO", __FUNCTION__, __FILE__, __LINE__)) + "%s(%s:%" PRIuz ") NTLM_VERSION_INFO", __FUNCTION__, __FILE__, (size_t)__LINE__)) return FALSE; Stream_Write_UINT8(s, versionInfo->ProductMajorVersion); /* ProductMajorVersion (1 byte) */ diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_message.c b/winpr/libwinpr/sspi/NTLM/ntlm_message.c index eae8d3ccb..c095bdcff 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_message.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_message.c @@ -37,7 +37,7 @@ #define NTLM_CheckAndLogRequiredCapacity(tag, s, nmemb, what) \ Stream_CheckAndLogRequiredCapacityEx(tag, WLOG_WARN, s, nmemb, 1, "%s(%s:%" PRIuz ") " what, \ - __FUNCTION__, __FILE__, __LINE__) + __FUNCTION__, __FILE__, (size_t)__LINE__) static const char NTLM_SIGNATURE[8] = { 'N', 'T', 'L', 'M', 'S', 'S', 'P', '\0' }; @@ -437,7 +437,7 @@ static BOOL ntlm_write_negotiate_flags(wStream* s, UINT32 flags, const char* nam if (!Stream_CheckAndLogRequiredCapacityEx(TAG, WLOG_WARN, s, 4ull, 1ull, "%s(%s:%" PRIuz ") %s::NegotiateFlags", __FUNCTION__, - __FILE__, __LINE__, name)) + __FILE__, (size_t)__LINE__, name)) return FALSE; WLog_DBG(TAG, "Write flags %s", ntlm_negotiate_flags_string(buffer, ARRAYSIZE(buffer), flags)); diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c index 37e73fe12..7ee3150ca 100644 --- a/winpr/libwinpr/utils/stream.c +++ b/winpr/libwinpr/utils/stream.c @@ -35,7 +35,7 @@ if (!(cond)) \ { \ WLog_FATAL(STREAM_TAG, "%s [%s:%s:%" PRIuz "]", #cond, __FILE__, __FUNCTION__, \ - __LINE__); \ + (size_t)__LINE__); \ winpr_log_backtrace(STREAM_TAG, WLOG_FATAL, 20); \ abort(); \ } \