]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
MinGW: PRINTF_FORMAT_ARG workaround (#1390)
authorAmos Jeffries <yadij@users.noreply.github.com>
Sat, 22 Jul 2023 17:30:22 +0000 (17:30 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 22 Jul 2023 17:30:37 +0000 (17:30 +0000)
MinGW produces warnings about not supporting the printf '%zu' format
code when the 'printf' format archetype is used to validate code.

Checking against the 'gnu_printf' format archetype avoids this bad
warning. We accept the lower rate of error detection since other OS
builds verify against the 'printf' format archetype.

We also removed undocumented, inconsistent, and presumably unused
support for providing custom PRINTF_FORMAT_ARG macros during Squid
build. This removal simplifies code.

compat/compat_shared.h
compat/os/mswindows.h

index e29d6762c15607c07fd3de765db841fac559d328..79d0caa24b3b05e81b68b53ea6af7f52ee31558c 100644 (file)
@@ -239,15 +239,15 @@ const char * squid_strnstr(const char *s, const char *find, size_t slen);
 #endif
 
 #if __GNUC__
-#if !defined(PRINTF_FORMAT_ARG1)
+#if _SQUID_MINGW_
+#define PRINTF_FORMAT_ARG1 __attribute__ ((format (gnu_printf, 1, 2)))
+#define PRINTF_FORMAT_ARG2 __attribute__ ((format (gnu_printf, 2, 3)))
+#define PRINTF_FORMAT_ARG3 __attribute__ ((format (gnu_printf, 3, 4)))
+#else
 #define PRINTF_FORMAT_ARG1 __attribute__ ((format (printf, 1, 2)))
-#endif
-#if !defined(PRINTF_FORMAT_ARG2)
 #define PRINTF_FORMAT_ARG2 __attribute__ ((format (printf, 2, 3)))
-#endif
-#if !defined(PRINTF_FORMAT_ARG3)
 #define PRINTF_FORMAT_ARG3 __attribute__ ((format (printf, 3, 4)))
-#endif
+#endif /* !_SQUID_MINGW_ */
 #else /* !__GNU__ */
 #define PRINTF_FORMAT_ARG1
 #define PRINTF_FORMAT_ARG2
index 6b29f47b09415d7d43f185277ca3ae320edeaf68..5446bb8adb04b727dd4ceed85f5da138e70f43a4 100644 (file)
@@ -885,15 +885,6 @@ SQUIDCEXTERN void WIN32_ExceptionHandlerInit(void);
 SQUIDCEXTERN int Win32__WSAFDIsSet(int fd, fd_set* set);
 SQUIDCEXTERN DWORD WIN32_IpAddrChangeMonitorInit();
 
-/* gcc doesn't recognize the Windows native 64 bit formatting tags causing
- * the compile fail, so we must disable the check on native Windows.
- */
-#if __GNUC__
-#define PRINTF_FORMAT_ARG1
-#define PRINTF_FORMAT_ARG2
-#define PRINTF_FORMAT_ARG3
-#endif
-
 /* XXX: the logic around this is a bit warped:
  *   we #define ACL unconditionally at the top of this file,
  *   then #undef ACL unconditionally hafway down,