[openib-general] [PATCH 2/2 v2] libibcommon: enable printf() style format strict checking
Sasha Khapyorsky
sashak at voltaire.com
Thu Nov 16 16:38:32 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..c41217d 100644
--- a/libibcommon/include/infiniband/common.h
+++ b/libibcommon/include/infiniband/common.h
@@ -114,11 +114,16 @@ static inline uint64_t htonll(uint64_t x
#define ENUM_STR_DEF(enumname, last, val) (((unsigned)(val) < last) ? enumname ## _str[val] : "???")
#define ENUM_STR_ARRAY(name) char * name ## _str[]
+#ifdef __GNUC__
+#define IBCOMMON_STRICT_FORMAT __attribute__((format(printf, 2, 3)))
+#else
+#define IBCOMMON_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, ...) IBCOMMON_STRICT_FORMAT;
+void ibpanic(const char * const fn, char *msg, ...) IBCOMMON_STRICT_FORMAT;
+void logmsg(const char *const fn, char *msg, ...) IBCOMMON_STRICT_FORMAT;
void xdump(FILE *file, char *msg, void *p, int size);
--
1.4.4.g031c-dirty
More information about the general
mailing list