]> mj.ucw.cz Git - pciutils.git/commitdiff
libpci: For MSVC < 19.00 define snprintf outside of endian section
authorPali Rohár <pali@kernel.org>
Sun, 26 Dec 2021 23:47:53 +0000 (00:47 +0100)
committerMartin Mares <mj@ucw.cz>
Thu, 10 Feb 2022 11:58:17 +0000 (12:58 +0100)
snprintf() macro is not endian specific and therefore should be declared
outside of the endian section.

This also fixes snprintf() function for new MinGW-w64 toolchains where
snprintf() is defined as wrapper around _snprintf() which do not return
negative value on overflow. libpci would call MinGW-w64 patched snprintf()
function and not broken system function _snprintf().

lib/sysdep.h

index 462fd355cf7b6c04a93fbe5c13f0d1fc4c770eda..1986d9f41c59d0f4a60ec4c88be022f16de0c2e0 100644 (file)
@@ -23,6 +23,7 @@ typedef u16 word;
 #ifdef PCI_OS_WINDOWS
 #define strcasecmp _strcmpi
 #if defined(_MSC_VER) && _MSC_VER < 1900
+#define snprintf _snprintf
 #define vsnprintf _vsnprintf
 #endif
 #endif
@@ -69,7 +70,6 @@ typedef u16 word;
   #define BIG_ENDIAN 4321
   #define LITTLE_ENDIAN        1234
   #define BYTE_ORDER LITTLE_ENDIAN
-  #define snprintf _snprintf
 #endif
 #endif