[PATCH v2 libevdev] Mark the log functions with the printf format attribute

Peter Hutterer peter.hutterer at who-t.net
Mon May 26 17:27:51 PDT 2014


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to v1:
- predefine macro for doxygen to avoid broken output
- unconditionally define the attribute, don't worry about compilers that
  don't support this

 doc/libevdev.doxygen.in | 6 +++---
 libevdev/libevdev-int.h | 3 +--
 libevdev/libevdev.h     | 5 ++++-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/doc/libevdev.doxygen.in b/doc/libevdev.doxygen.in
index b46a4d7..853c47d 100644
--- a/doc/libevdev.doxygen.in
+++ b/doc/libevdev.doxygen.in
@@ -1537,13 +1537,13 @@ ENABLE_PREPROCESSING   = YES
 # compilation will be performed. Macro expansion can be done in a controlled
 # way by setting EXPAND_ONLY_PREDEF to YES.
 
-MACRO_EXPANSION        = NO
+MACRO_EXPANSION        = YES
 
 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
 # then the macro expansion is limited to the macros specified with the
 # PREDEFINED and EXPAND_AS_DEFINED tags.
 
-EXPAND_ONLY_PREDEF     = NO
+EXPAND_ONLY_PREDEF     = YES
 
 # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
 # pointed to by INCLUDE_PATH will be searched when a #include is found.
@@ -1571,7 +1571,7 @@ INCLUDE_FILE_PATTERNS  =
 # undefined via #undef or recursively expanded use the := operator
 # instead of the = operator.
 
-PREDEFINED             =
+PREDEFINED             = LIBEVDEV_ATTRIBUTE_PRINTF(f,a)=
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
 # this tag can be used to specify a list of macro names that should be expanded.
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 a74d24c..6c03cce 100644
--- a/libevdev/libevdev.h
+++ b/libevdev/libevdev.h
@@ -30,6 +30,8 @@ extern "C" {
 #include <linux/input.h>
 #include <stdarg.h>
 
+#define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args)))
+
 /**
  * @mainpage
  *
@@ -790,7 +792,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.3



More information about the Input-tools mailing list