From: Amos Jeffries Date: Sat, 22 Jul 2023 17:30:22 +0000 (+0000) Subject: MinGW: PRINTF_FORMAT_ARG workaround (#1390) X-Git-Tag: SQUID_7_0_1~392 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f43562f5115d4696fadb7ad0379a1301ff803598;p=thirdparty%2Fsquid.git MinGW: PRINTF_FORMAT_ARG workaround (#1390) 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. --- diff --git a/compat/compat_shared.h b/compat/compat_shared.h index e29d6762c1..79d0caa24b 100644 --- a/compat/compat_shared.h +++ b/compat/compat_shared.h @@ -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 diff --git a/compat/os/mswindows.h b/compat/os/mswindows.h index 6b29f47b09..5446bb8adb 100644 --- a/compat/os/mswindows.h +++ b/compat/os/mswindows.h @@ -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,