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: Eric Blake <eblake@redhat.com> Message-Id: <1459913704-19949-3-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
c0301fcc81
commit
8c6597123a
|
@ -33,18 +33,21 @@
|
||||||
/* #define DEBUG_NBD */
|
/* #define DEBUG_NBD */
|
||||||
|
|
||||||
#ifdef DEBUG_NBD
|
#ifdef DEBUG_NBD
|
||||||
#define TRACE(msg, ...) do { \
|
#define DEBUG_NBD_PRINT 1
|
||||||
LOG(msg, ## __VA_ARGS__); \
|
|
||||||
} while(0)
|
|
||||||
#else
|
#else
|
||||||
#define TRACE(msg, ...) \
|
#define DEBUG_NBD_PRINT 0
|
||||||
do { } while (0)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TRACE(msg, ...) do { \
|
||||||
|
if (DEBUG_NBD_PRINT) { \
|
||||||
|
LOG(msg, ## __VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LOG(msg, ...) do { \
|
#define LOG(msg, ...) do { \
|
||||||
fprintf(stderr, "%s:%s():L%d: " msg "\n", \
|
fprintf(stderr, "%s:%s():L%d: " msg "\n", \
|
||||||
__FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
|
__FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
|
||||||
} while(0)
|
} while (0)
|
||||||
|
|
||||||
/* This is all part of the "official" NBD API.
|
/* This is all part of the "official" NBD API.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue