[openib-general] [PATCH 2/2] libibcommon: enable printf() style format strict checking

Sasha Khapyorsky sashak at voltaire.com
Thu Nov 16 06:58:17 PST 2006


This enables strict format/args checking for printf() style functions.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 libibcommon/include/infiniband/common.h |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libibcommon/include/infiniband/common.h b/libibcommon/include/infiniband/common.h
index 83c0679..66afab0 100644
--- a/libibcommon/include/infiniband/common.h
+++ b/libibcommon/include/infiniband/common.h
@@ -114,11 +114,16 @@ #endif
 #define ENUM_STR_DEF(enumname, last, val) 	(((unsigned)(val) < last) ? enumname ## _str[val] : "???")
 #define ENUM_STR_ARRAY(name)		char * name ## _str[]
 
+#ifdef __GNUC__
+#define STRICT_FORMAT __attribute__((format(printf, 2, 3)))
+#else
+#define STRICT_FORMAT
+#endif
 
 /* util.c: debugging and tracing */
-void	ibwarn(const char * const fn, char *msg, ...);
-void	ibpanic(const char * const fn, char *msg, ...);
-void	logmsg(const char *const fn, char *msg, ...);
+void	ibwarn(const char * const fn, char *msg, ...) STRICT_FORMAT;
+void	ibpanic(const char * const fn, char *msg, ...) STRICT_FORMAT;
+void	logmsg(const char *const fn, char *msg, ...) STRICT_FORMAT;
 
 void	xdump(FILE *file, char *msg, void *p, int size);
 
-- 
1.4.3.2.g4bf7





More information about the general mailing list