mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
Avoid printf type modifiers not supported by MSVC C runtime library.
The MSVC C library printf() implementation does not support the 'z', 't', 'j', or 'hh' format specifiers. This commit changes the Open vSwitch code to avoid those format specifiers, switching to standard macros from <inttypes.h> where available and inventing new macros resembling them where necessary. It also updates CodingStyle to specify the macros' use and adds a Makefile rule to report violations. Signed-off-by: Alin Serdean <aserdean@cloudbasesolutions.com> Co-authored-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -346,7 +346,7 @@ ovs_strerror(int error)
|
||||
* is too short). We don't check the actual failure reason because
|
||||
* POSIX requires strerror_r() to return the error but old glibc
|
||||
* (before 2.13) returns -1 and sets errno. */
|
||||
snprintf(buffer, BUFSIZE, "Unknown error %d", error);
|
||||
snprintf(buffer, BUFSIZE, "Unknown error %"PRIuSIZE, error);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -473,11 +473,11 @@ ovs_hex_dump(FILE *stream, const void *buf_, size_t size,
|
||||
n = end - start;
|
||||
|
||||
/* Print line. */
|
||||
fprintf(stream, "%08jx ", (uintmax_t) ROUND_DOWN(ofs, per_line));
|
||||
fprintf(stream, "%08"PRIxMAX" ", (uintmax_t) ROUND_DOWN(ofs, per_line));
|
||||
for (i = 0; i < start; i++)
|
||||
fprintf(stream, " ");
|
||||
for (; i < end; i++)
|
||||
fprintf(stream, "%02hhx%c",
|
||||
fprintf(stream, "%02x%c",
|
||||
buf[i - start], i == per_line / 2 - 1? '-' : ' ');
|
||||
if (ascii)
|
||||
{
|
||||
|
Reference in New Issue
Block a user