Replies: 8 comments 4 replies
-
I found another such warning: vtls/x509asn1.c(976,44): warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned long long')
[-Wformat]
(void)msnprintf(q, sizeof(q), "%lu", len);
~~~ ^~~
%zu
vtls/x509asn1.c(1010,38): warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned long long')
[-Wformat]
msnprintf(r, sizeof(r), "%lu", len);
~~~ ^~~
%zu |
Beta Was this translation helpful? Give feedback.
-
I believe DWORD is usually typedef'ed as an unsigned long, but that is also 32 bits on Windows so %u or %lu makes no difference to the printf() code. On Windows, ints and longs are virtually the same. It seems next to silly to generate a warning for this. But yes, if that code runs on other platforms than windows then %u vs %lu diff is meaningful.
They're actually close to compatible but not quite. The biggest difference is probably in return code, but there might also be some subtle differences in flag treatment. This minor incompatibility is one of the reasons why I've hesitated to make our own *printf() code conditional and instead stick to using it everywhere. That's also why adding |
Beta Was this translation helpful? Give feedback.
-
Like Cygwin (a LP64 platform). I've not tried it. But I'd assume it would compile with a lot of noise if such |
Beta Was this translation helpful? Give feedback.
-
Using the
|
Beta Was this translation helpful? Give feedback.
-
Never heard of hexlen = msnprintf(hexbuffer, sizeof(hexbuffer), "%.*s", (int)nread, endofline_native); |
Beta Was this translation helpful? Give feedback.
-
'z' - A following integer conversion corresponds to a size_t or ssize_t argument, or a following n conversion corresponds to a pointer to a size_t argument. |
Beta Was this translation helpful? Give feedback.
-
see #11589 |
Beta Was this translation helpful? Give feedback.
-
attributes have been added! |
Beta Was this translation helpful? Give feedback.
-
I see in
lib/strerror.c
that a%u
is used for aDWORD
value:I would assume
curl_msnprintf()
should beprintf()
compatible. Now this compiles w/o a warning since there is no__attribute__((format(printf,3,4))
on this function. So adding support for that, I now get from clang-cl:So would it be an idea to add stuff like this:
(and
_Printf_format_string_
for MSVC) for allcurl_*printf()
functions?Beta Was this translation helpful? Give feedback.
All reactions