From 3ad560815ae9f143a0851b43454e66d26f18888d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 14 Apr 2015 11:05:44 +0100 Subject: stun: Add missing format attributes for va_list printf functions As detected by GCC 4.9. --- agent/debug.c | 3 +++ stun/debug.c | 9 +++++++++ stun/debug.h | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/agent/debug.c b/agent/debug.c index b4167d8..6e69f9b 100644 --- a/agent/debug.c +++ b/agent/debug.c @@ -62,6 +62,9 @@ static const GDebugKey keys[] = { { NULL, 0}, }; +static void +stun_handler (const char *format, va_list ap) G_GNUC_PRINTF (1, 0); + static void stun_handler (const char *format, va_list ap) { diff --git a/stun/debug.c b/stun/debug.c index 3d579db..2b4ec59 100644 --- a/stun/debug.c +++ b/stun/debug.c @@ -55,6 +55,15 @@ void stun_debug_disable (void) { debug_enabled = 0; } +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#define GNUC_PRINTF(format_idx, arg_idx) \ + __attribute__((__format__ (__printf__, format_idx, arg_idx))) +#else +#define GNUC_PRINTF( format_idx, arg_idx) +#endif + +static void +default_handler (const char *format, va_list ap) GNUC_PRINTF (1, 0); static void default_handler (const char *format, va_list ap) diff --git a/stun/debug.h b/stun/debug.h index d4884d5..47a6114 100644 --- a/stun/debug.h +++ b/stun/debug.h @@ -66,7 +66,12 @@ void stun_debug_disable (void); * * Callback for a debug message from the STUN code. */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)) +typedef void (*StunDebugHandler) (const char *format, va_list ap) + __attribute__((__format__ (__printf__, 1, 0))); +#else typedef void (*StunDebugHandler) (const char *format, va_list ap); +#endif /** * stun_set_debug_handler: -- cgit v1.2.1