[PATCH libevdev 2/3] Mark the log functions with the printf format attribute

Peter Hutterer peter.hutterer at who-t.net
Sun May 18 21:01:50 PDT 2014


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 configure.ac            |  1 +
 libevdev/libevdev-int.h |  3 +--
 libevdev/libevdev.h     | 10 +++++++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0f2755e..9c0aae3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,7 @@ AM_SILENT_RULES([yes])
 
 # Check for programs
 AC_PROG_CC_C99
+CC_ATTRIBUTE_FORMAT
 
 # Initialize libtool
 LT_PREREQ([2.2])
diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h
index 98c75ce..f587e76 100644
--- a/libevdev/libevdev-int.h
+++ b/libevdev/libevdev-int.h
@@ -36,7 +36,6 @@
 #define ABS_MT_MAX ABS_MT_TOOL_Y
 #define ABS_MT_CNT (ABS_MT_MAX - ABS_MT_MIN + 1)
 #define LIBEVDEV_EXPORT __attribute__((visibility("default")))
-#define LIBEVDEV_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args)))
 #define ALIAS(_to) __attribute__((alias(#_to)))
 
 /**
@@ -131,7 +130,7 @@ extern void
 log_msg(enum libevdev_log_priority priority,
 	void *data,
 	const char *file, int line, const char *func,
-	const char *format, ...) LIBEVDEV_PRINTF(6, 7);
+	const char *format, ...) LIBEVDEV_ATTRIBUTE_PRINTF(6, 7);
 
 /**
  * @return a pointer to the next element in the queue, or NULL if the queue
diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h
index ef142ea..2c46102 100644
--- a/libevdev/libevdev.h
+++ b/libevdev/libevdev.h
@@ -30,6 +30,13 @@ extern "C" {
 #include <linux/input.h>
 #include <stdarg.h>
 
+#undef LIBEVDEV_ATTRIBUTE_PRINTF
+#ifdef SUPPORT_ATTRIBUTE_FORMAT
+#define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args)))
+#else
+#define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args) /**/
+#endif
+
 /**
  * @mainpage
  *
@@ -789,7 +796,8 @@ typedef void (*libevdev_log_func_t)(enum libevdev_log_priority priority,
 				    void *data,
 				    const char *file, int line,
 				    const char *func,
-				    const char *format, va_list args);
+				    const char *format, va_list args)
+	LIBEVDEV_ATTRIBUTE_PRINTF(6, 0);
 
 /**
  * @ingroup init
-- 
1.9.0



More information about the Input-tools mailing list