提交 8c659712 编写于 作者: E Eric Blake 提交者: Paolo Bonzini

nbd: Avoid bitrot in TRACE() usage

The compiler is smart enough to optimize out 'if (0)', but won't
type-check our printfs if they are hidden behind #if.
Signed-off-by: NEric Blake <eblake@redhat.com>
Message-Id: <1459913704-19949-3-git-send-email-eblake@redhat.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 c0301fcc
......@@ -33,18 +33,21 @@
/* #define DEBUG_NBD */
#ifdef DEBUG_NBD
#define TRACE(msg, ...) do { \
LOG(msg, ## __VA_ARGS__); \
} while(0)
#define DEBUG_NBD_PRINT 1
#else
#define TRACE(msg, ...) \
do { } while (0)
#define DEBUG_NBD_PRINT 0
#endif
#define TRACE(msg, ...) do { \
if (DEBUG_NBD_PRINT) { \
LOG(msg, ## __VA_ARGS__); \
} \
} while (0)
#define LOG(msg, ...) do { \
fprintf(stderr, "%s:%s():L%d: " msg "\n", \
__FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
} while(0)
} while (0)
/* This is all part of the "official" NBD API.
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册