mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Let GCC check format arguments
This commit is contained in:
parent
095efa09af
commit
5ef7cc4cb6
3 changed files with 11 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue