From eb1e6d0cb457e67a61b1e5d0c2a3360d1f98cd7c Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Wed, 16 May 2012 13:15:34 +0000 Subject: [PATCH] Check log_put() printf-like format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Romain Tartière for the patch http://groups.google.com/group/libnfc-devel/browse_thread/thread/da352d67e6965851 --- libnfc/log.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libnfc/log.h b/libnfc/log.h index 40d3b2e..264a00b 100644 --- a/libnfc/log.h +++ b/libnfc/log.h @@ -23,11 +23,25 @@ #endif // HAVE_CONFIG_H #if defined DEBUG + +# ifndef __has_attribute +# define __has_attribute(x) 0 +# endif + +# if __has_attribute(format) || defined(__GNUC__) +# define __has_attribute_format 1 +# endif + // User want debug features #define LOGGING 1 int log_init (void); int log_fini (void); - void log_put (const char *category, const char *priority, const char *format, ...); + void log_put (const char *category, const char *priority, const char *format, ...) +# if __has_attribute_format + __attribute__((format(printf, 3, 4))) +# endif + ; + #define NFC_PRIORITY_FATAL "fatal" #define NFC_PRIORITY_ALERT "alert"