[warnings] add WINPR_FORMAT_ARG

with WINPR_FORMAT_ARG format strings are marked for MSVC to avoid
warnings
This commit is contained in:
Armin Novak 2023-10-11 15:21:15 +02:00 committed by akallabeth
parent 53b65ff7bd
commit c91a250623
10 changed files with 20 additions and 15 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

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

View File

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

View File

@ -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)));

View File

@ -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)

View File

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

View File

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

View File

@ -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);