[ofa-general] [PATCH] infiniabnd-diags/common: wrap debug macros with do {} while (0)

Sasha Khapyorsky sashak at voltaire.com
Sat Feb 14 07:37:34 PST 2009


Wrap debug macros which use 'if () {}' with 'do { .. } while (0)' to
prevent potential 'else' statement mismatching. Also use portable
__VA_ARGS__ macro.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 infiniband-diags/include/ibdiag_common.h |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/infiniband-diags/include/ibdiag_common.h b/infiniband-diags/include/ibdiag_common.h
index 4783b8e..52fd147 100644
--- a/infiniband-diags/include/ibdiag_common.h
+++ b/infiniband-diags/include/ibdiag_common.h
@@ -50,9 +50,13 @@ extern int ibd_timeout;
 /*========================================================*/
 
 #undef DEBUG
-#define	DEBUG	if (ibdebug || ibverbose) IBWARN
-#define	VERBOSE	if (ibdebug || ibverbose > 1) IBWARN
-#define IBERROR(fmt, args...)	iberror(__FUNCTION__, fmt, ## args)
+#define DEBUG(fmt, ...) do { \
+	if (ibdebug || ibverbose) IBWARN(fmt, ## __VA_ARGS__); \
+} while (0)
+#define VERBOSE(fmt, ...) do { \
+	if (ibdebug || ibverbose > 1) IBWARN(fmt, ## __VA_ARGS__); \
+} while (0)
+#define IBERROR(fmt, ...) iberror(__FUNCTION__, fmt, ## __VA_ARGS__)
 
 struct ibdiag_opt {
 	const char *name;
-- 
1.6.1.2.319.gbd9e




More information about the general mailing list