qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 42/43] pci-bridge: made printf always compile in debug output
@ 2017-04-01 14:09 Danil Antonov
  0 siblings, 0 replies; only message in thread
From: Danil Antonov @ 2017-04-01 14:09 UTC (permalink / raw)
  To: qemu-devel, agraf

>From bd32eaf17d401067d46891facfa37fe2a315cd2a Mon Sep 17 00:00:00 2001
From: Danil Antonov <g.danil.anto@gmail.com>
Date: Wed, 29 Mar 2017 12:44:02 +0300
Subject: [PATCH 42/43] pci-bridge: made printf always compile in debug
output

Wrapped printf calls inside debug macros (DPRINTF) in `if` statement.
This will ensure that printf function will always compile even if debug
output is turned off and, in turn, will prevent bitrot of the format
strings.

Signed-off-by: Danil Antonov <g.danil.anto@gmail.com>
---
 hw/pci-bridge/dec.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/hw/pci-bridge/dec.c b/hw/pci-bridge/dec.c
index 840c961..84149da 100644
--- a/hw/pci-bridge/dec.c
+++ b/hw/pci-bridge/dec.c
@@ -32,14 +32,16 @@
 #include "hw/pci/pci_bus.h"

 /* debug DEC */
-//#define DEBUG_DEC
-
-#ifdef DEBUG_DEC
-#define DEC_DPRINTF(fmt, ...)                               \
-    do { printf("DEC: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DEC_DPRINTF(fmt, ...)
-#endif
+
+#ifndef DEBUG_DEC
+#define DEBUG_DEC 0
+#endif
+
+#define DEC_DPRINTF(fmt, ...) do {                     \
+    if (DEBUG_DEC) {                                   \
+        fprintf(stderr, "DEC: " fmt , ## __VA_ARGS__); \
+    }                                                  \
+} while (0);

 #define DEC_21154(obj) OBJECT_CHECK(DECState, (obj), TYPE_DEC_21154)

-- 
2.8.0.rc3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-01 14:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-01 14:09 [Qemu-devel] [PATCH 42/43] pci-bridge: made printf always compile in debug output Danil Antonov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).