From c91a250623748f342c23c97498d32fbb008a6510 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 11 Oct 2023 15:21:15 +0200 Subject: [PATCH] [warnings] add WINPR_FORMAT_ARG with WINPR_FORMAT_ARG format strings are marked for MSVC to avoid warnings --- channels/urbdrc/client/libusb/libusb_udevice.c | 4 ++-- libfreerdp/core/aad.c | 2 +- libfreerdp/core/freerdp.c | 2 +- libfreerdp/core/gateway/http.c | 2 +- libfreerdp/core/gateway/tsg.c | 2 +- server/Sample/sfreerdp.c | 2 +- winpr/include/winpr/winpr.h | 2 ++ winpr/libwinpr/crt/string.c | 2 +- winpr/libwinpr/utils/stream.c | 10 ++++++---- winpr/libwinpr/utils/wlog/Layout.c | 7 ++++--- 10 files changed, 20 insertions(+), 15 deletions(-) diff --git a/channels/urbdrc/client/libusb/libusb_udevice.c b/channels/urbdrc/client/libusb/libusb_udevice.c index dd484352a..2117be380 100644 --- a/channels/urbdrc/client/libusb/libusb_udevice.c +++ b/channels/urbdrc/client/libusb/libusb_udevice.c @@ -131,8 +131,8 @@ static void set_stream_id_for_buffer(struct libusb_transfer* transfer, UINT32 st } WINPR_ATTR_FORMAT_ARG(3, 8) -static BOOL log_libusb_result_(wLog* log, DWORD lvl, const char* fmt, const char* fkt, - const char* file, size_t line, int error, ...) +static BOOL log_libusb_result_(wLog* log, DWORD lvl, WINPR_FORMAT_ARG const char* fmt, + const char* fkt, const char* file, size_t line, int error, ...) { WINPR_UNUSED(file); diff --git a/libfreerdp/core/aad.c b/libfreerdp/core/aad.c index 1c21bc9c0..b4d132cb6 100644 --- a/libfreerdp/core/aad.c +++ b/libfreerdp/core/aad.c @@ -53,7 +53,7 @@ static BOOL get_encoded_rsa_params(wLog* wlog, rdpPrivateKey* key, char** e, cha static BOOL generate_pop_key(rdpAad* aad); WINPR_ATTR_FORMAT_ARG(2, 3) -static SSIZE_T stream_sprintf(wStream* s, const char* fmt, ...) +static SSIZE_T stream_sprintf(wStream* s, WINPR_FORMAT_ARG const char* fmt, ...) { va_list ap; va_start(ap, fmt); diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 7f7d3ac6f..316d3f4a5 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -1211,7 +1211,7 @@ void clearChannelError(rdpContext* context) } WINPR_ATTR_FORMAT_ARG(3, 4) -void setChannelError(rdpContext* context, UINT errorNum, const char* format, ...) +void setChannelError(rdpContext* context, UINT errorNum, WINPR_FORMAT_ARG const char* format, ...) { va_list ap; va_start(ap, format); diff --git a/libfreerdp/core/gateway/http.c b/libfreerdp/core/gateway/http.c index d1d185760..0bdec045b 100644 --- a/libfreerdp/core/gateway/http.c +++ b/libfreerdp/core/gateway/http.c @@ -469,7 +469,7 @@ BOOL http_request_set_transfer_encoding(HttpRequest* request, TRANSFER_ENCODING } WINPR_ATTR_FORMAT_ARG(2, 3) -static BOOL http_encode_print(wStream* s, const char* fmt, ...) +static BOOL http_encode_print(wStream* s, WINPR_FORMAT_ARG const char* fmt, ...) { char* str; va_list ap; diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index a0d038d4c..239efbb8c 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -291,7 +291,7 @@ static const char* tsg_state_to_string(TSG_STATE state) } WINPR_ATTR_FORMAT_ARG(3, 4) -static BOOL tsg_print(char** buffer, size_t* len, const char* fmt, ...) +static BOOL tsg_print(char** buffer, size_t* len, WINPR_FORMAT_ARG const char* fmt, ...) { int rc; va_list ap; diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 036a4f74d..cdb3b3e51 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -1258,7 +1258,7 @@ static const struct } options = { "--pcap=", "--fast", "--port=", "--local-only", "--cert=", "--key=" }; WINPR_ATTR_FORMAT_ARG(2, 0) -static void print_entry(FILE* fp, const char* fmt, const char* what, size_t size) +static void print_entry(FILE* fp, WINPR_FORMAT_ARG const char* fmt, const char* what, size_t size) { char buffer[32] = { 0 }; strncpy(buffer, what, MIN(size, sizeof(buffer))); diff --git a/winpr/include/winpr/winpr.h b/winpr/include/winpr/winpr.h index 2e03fa2fb..dfd999f6d 100644 --- a/winpr/include/winpr/winpr.h +++ b/winpr/include/winpr/winpr.h @@ -49,8 +49,10 @@ #if defined(__GNUC__) || defined(__clang__) #define WINPR_ATTR_FORMAT_ARG(pos, args) __attribute__((__format__(__printf__, pos, args))) +#define WINPR_FORMAT_ARG /**/ #else #define WINPR_ATTR_FORMAT_ARG(pos, args) +#define WINPR_FORMAT_ARG _Printf_format_string_ #endif #if defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) diff --git a/winpr/libwinpr/crt/string.c b/winpr/libwinpr/crt/string.c index 8b873802d..7ff7fcb1d 100644 --- a/winpr/libwinpr/crt/string.c +++ b/winpr/libwinpr/crt/string.c @@ -176,7 +176,7 @@ BOOL winpr_str_append(const char* what, char* buffer, size_t size, const char* s } WINPR_ATTR_FORMAT_ARG(3, 4) -int winpr_asprintf(char** s, size_t* slen, const char* templ, ...) +int winpr_asprintf(char** s, size_t* slen, WINPR_FORMAT_ARG const char* templ, ...) { va_list ap; diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c index c4ae25645..86f316f32 100644 --- a/winpr/libwinpr/utils/stream.c +++ b/winpr/libwinpr/utils/stream.c @@ -348,7 +348,8 @@ BOOL Stream_CheckAndLogRequiredCapacityExVa(const char* tag, DWORD level, wStrea WINPR_ATTR_FORMAT_ARG(6, 0) BOOL Stream_CheckAndLogRequiredCapacityWLogExVa(wLog* log, DWORD level, wStream* s, size_t nmemb, - size_t size, const char* fmt, va_list args) + size_t size, WINPR_FORMAT_ARG const char* fmt, + va_list args) { WINPR_ASSERT(size != 0); @@ -372,7 +373,7 @@ BOOL Stream_CheckAndLogRequiredCapacityWLogExVa(wLog* log, DWORD level, wStream* WINPR_ATTR_FORMAT_ARG(6, 7) BOOL Stream_CheckAndLogRequiredCapacityWLogEx(wLog* log, DWORD level, wStream* s, size_t nmemb, - size_t size, const char* fmt, ...) + size_t size, WINPR_FORMAT_ARG const char* fmt, ...) { WINPR_ASSERT(size != 0); @@ -393,7 +394,7 @@ BOOL Stream_CheckAndLogRequiredCapacityWLogEx(wLog* log, DWORD level, wStream* s WINPR_ATTR_FORMAT_ARG(6, 7) BOOL Stream_CheckAndLogRequiredLengthEx(const char* tag, DWORD level, wStream* s, size_t nmemb, - size_t size, const char* fmt, ...) + size_t size, WINPR_FORMAT_ARG const char* fmt, ...) { WINPR_ASSERT(size > 0); const size_t actual = Stream_GetRemainingLength(s) / size; @@ -444,7 +445,8 @@ BOOL Stream_CheckAndLogRequiredLengthWLogEx(wLog* log, DWORD level, wStream* s, WINPR_ATTR_FORMAT_ARG(6, 0) BOOL Stream_CheckAndLogRequiredLengthWLogExVa(wLog* log, DWORD level, wStream* s, size_t nmemb, - size_t size, const char* fmt, va_list args) + size_t size, WINPR_FORMAT_ARG const char* fmt, + va_list args) { WINPR_ASSERT(size > 0); const size_t actual = Stream_GetRemainingLength(s) / size; diff --git a/winpr/libwinpr/utils/wlog/Layout.c b/winpr/libwinpr/utils/wlog/Layout.c index b9872bf4d..5f091a89d 100644 --- a/winpr/libwinpr/utils/wlog/Layout.c +++ b/winpr/libwinpr/utils/wlog/Layout.c @@ -71,15 +71,16 @@ struct format_option_recurse * Log Layout */ WINPR_ATTR_FORMAT_ARG(3, 0) -static void WLog_PrintMessagePrefixVA(wLog* log, wLogMessage* message, const char* format, - va_list args) +static void WLog_PrintMessagePrefixVA(wLog* log, wLogMessage* message, + WINPR_FORMAT_ARG const char* format, va_list args) { WINPR_ASSERT(message); vsnprintf(message->PrefixString, WLOG_MAX_PREFIX_SIZE - 1, format, args); } WINPR_ATTR_FORMAT_ARG(3, 4) -static void WLog_PrintMessagePrefix(wLog* log, wLogMessage* message, const char* format, ...) +static void WLog_PrintMessagePrefix(wLog* log, wLogMessage* message, + WINPR_FORMAT_ARG const char* format, ...) { va_list args; va_start(args, format);