From 5ef7cc4cb6b064828f1cd8d54eb97891142f9da4 Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Thu, 28 Aug 2003 05:23:08 +0000 Subject: [PATCH] Let GCC check format arguments --- main/php.h | 6 ++++++ main/snprintf.h | 6 +++--- main/spprintf.h | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/main/php.h b/main/php.h index 86fff71683..67206f76f2 100644 --- a/main/php.h +++ b/main/php.h @@ -226,6 +226,12 @@ char *strerror(int); #define LONG_MIN (- LONG_MAX - 1) #endif +#ifdef __GNUC__ +# define PHP_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first))) +#else +# define PHP_ATTRIBUTE_FORMAT(type, idx, first) +#endif + #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || PHP_BROKEN_SPRINTF || PHP_BROKEN_SNPRINTF || PHP_BROKEN_VSNPRINTF #include "snprintf.h" #endif diff --git a/main/snprintf.h b/main/snprintf.h index e786efe692..e810826a6e 100644 --- a/main/snprintf.h +++ b/main/snprintf.h @@ -65,17 +65,17 @@ Example: #define SNPRINTF_H #if !defined(HAVE_SNPRINTF) || PHP_BROKEN_SNPRINTF -extern int ap_php_snprintf(char *, size_t, const char *, ...); +int ap_php_snprintf(char *, size_t, const char *, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); #define snprintf ap_php_snprintf #endif #if !defined(HAVE_VSNPRINTF) || PHP_BROKEN_VSNPRINTF -extern int ap_php_vsnprintf(char *, size_t, const char *, va_list ap); +int ap_php_vsnprintf(char *, size_t, const char *, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0); #define vsnprintf ap_php_vsnprintf #endif #if PHP_BROKEN_SPRINTF -int php_sprintf (char* s, const char* format, ...); +int php_sprintf (char* s, const char* format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); #define sprintf php_sprintf #endif diff --git a/main/spprintf.h b/main/spprintf.h index 0d7f9fba57..a07881c3ff 100644 --- a/main/spprintf.h +++ b/main/spprintf.h @@ -37,9 +37,9 @@ There is also snprintf: See difference explained in snprintf.h #include "snprintf.h" BEGIN_EXTERN_C() -PHPAPI extern int spprintf( char **pbuf, size_t max_len, const char *format, ...); +PHPAPI int spprintf( char **pbuf, size_t max_len, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); -PHPAPI extern int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap); +PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0); END_EXTERN_C() #endif /* SNPRINTF_H */ -- 2.40.0