From 38139e707cce00f4ebe1f768dcddfbaeee9db9b3 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Sat, 23 Oct 2004 13:10:45 +0000 Subject: [PATCH] GCC 3.4 doesn't check for NULL format-strings for __attribute__((printf)) by default. Therefore the __printflike macro has to include a nonnull attribute too, which printf0like doesn't need. This makes the macros work as expected again. --- sys/sys/cdefs.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 091a2f3d9c..8d75b0a853 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -35,7 +35,7 @@ * * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 * $FreeBSD: src/sys/sys/cdefs.h,v 1.28.2.8 2002/09/18 04:05:13 mikeh Exp $ - * $DragonFly: src/sys/sys/cdefs.h,v 1.11 2004/08/27 12:08:41 joerg Exp $ + * $DragonFly: src/sys/sys/cdefs.h,v 1.12 2004/10/23 13:10:45 joerg Exp $ */ #ifndef _SYS_CDEFS_H_ @@ -221,13 +221,27 @@ * or scanf-like arguments. They are null except for versions of gcc * that are known to support the features properly (old versions of gcc-2 * didn't permit keeping the keywords out of the application namespace). + * + * The printf0like macro for GCC 2 uses DragonFly specific compiler extensions. */ #if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 7 #define __printflike(fmtarg, firstvararg) #define __scanflike(fmtarg, firstvararg) +#define __printf0like(fmtarg, firstvararg) +#elif __GNUC__ >= 3 +#define __printflike(fmtarg, firstvararg) \ + __attribute__((__nonnull__(fmtarg), \ + __format__ (__printf__, fmtarg, firstvararg))) +#define __printf0like(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf__, fmtarg, firstvararg))) +#define __scanflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) + #else #define __printflike(fmtarg, firstvararg) \ __attribute__((__format__ (__printf__, fmtarg, firstvararg))) +#define __printf0like(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) #define __scanflike(fmtarg, firstvararg) \ __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) #endif @@ -238,14 +252,6 @@ #define __ARRAY_ZERO #endif -/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */ -#if defined(__DragonFly__) || __FreeBSD_cc_version >= 300001 -#define __printf0like(fmtarg, firstvararg) \ - __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) -#else -#define __printf0like(fmtarg, firstvararg) -#endif - /* * Handy GCC based macros: * -- 2.41.0