[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/15] nbd: Avoid bitrot in TRACE() usage
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 05/15] nbd: Avoid bitrot in TRACE() usage |
Date: |
Thu, 7 Apr 2016 18:50:35 +0200 |
From: Eric Blake <address@hidden>
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 <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
nbd/nbd-internal.h | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h
index d09b4ee..3791535 100644
--- a/nbd/nbd-internal.h
+++ b/nbd/nbd-internal.h
@@ -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.
*
--
2.5.5
- [Qemu-devel] [PULL 00/15] Misc patches for QEMU 2.6.0-rc2, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 01/15] ps2kbd: default to scancode_set 2, as with KBD_CMD_RESET, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 02/15] hw/timer: Revert "hpet: inverse polarity when pin above ISA_NUM_IRQS", Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 03/15] docs: fix typo in memory.txt, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 04/15] nbd: Return correct error for write to read-only export, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 05/15] nbd: Avoid bitrot in TRACE() usage,
Paolo Bonzini <=
- [Qemu-devel] [PULL 06/15] nbd: Improve debug traces on little-endian, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 07/15] qemu-nbd: Document -x option, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 08/15] nbd: Fix NBD unsupported options, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 09/15] nbd: Don't kill server when client requests unknown option, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 10/15] nbd: do not hang nbd_wr_syncv if outside a coroutine and no available data, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 11/15] spapr: fix possible Negative array index read, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 13/15] translate-all: add missing fold of tb_ctx into tcg_ctx, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 12/15] hostmem-file: fix memory leak, Paolo Bonzini, 2016/04/07
- [Qemu-devel] [PULL 14/15] tests: ignore test-logging, Paolo Bonzini, 2016/04/07