diff mbox

[05/14] pci-host: Convert conditional compilation of debug printfs to regular ifs

Message ID 1398673575-7773-5-git-send-email-marc.mari.barcelo@gmail.com
State New
Headers show

Commit Message

Marc Marí April 28, 2014, 8:26 a.m. UTC
From: Marc Marí <5.markmb.5@gmail.com>

Modify debug macros as explained in https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg03642.html

Signed-off-by: Marc Marí <5.markmb.5@gmail.com>
---
 hw/pci-host/bonito.c  |   15 ++++++++++-----
 hw/pci-host/ppce500.c |   15 +++++++++++----
 2 files changed, 21 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index 902441f..cfd4dc4 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -47,14 +47,19 @@ 
 #include "sysemu/sysemu.h"
 #include "exec/address-spaces.h"
 
-//#define DEBUG_BONITO
+//#define DEBUG_BONITO 1
 
-#ifdef DEBUG_BONITO
-#define DPRINTF(fmt, ...) fprintf(stderr, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
-#else
-#define DPRINTF(fmt, ...)
+#ifndef DEBUG_BONITO
+#define DEBUG_BONITO 0
 #endif
 
+#define DPRINTF(fmt, ...) \
+    do { \
+        if(DEBUG_BONITO) { \
+            fprintf(stderr, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__); \
+        } \
+    } while(0)
+
 /* from linux soure code. include/asm-mips/mips-boards/bonito64.h*/
 #define BONITO_BOOT_BASE        0x1fc00000
 #define BONITO_BOOT_SIZE        0x00100000
diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c
index c80b7cb..4bfc212 100644
--- a/hw/pci-host/ppce500.c
+++ b/hw/pci-host/ppce500.c
@@ -21,12 +21,19 @@ 
 #include "qemu/bswap.h"
 #include "hw/pci-host/ppce500.h"
 
-#ifdef DEBUG_PCI
-#define pci_debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
-#else
-#define pci_debug(fmt, ...)
+//#define DEBUG_PCI 1
+
+#ifndef DEBUG_PCI
+#define DEBUG_PCI 0
 #endif
 
+#define pci_debug(fmt, ...) \
+    do { \
+        if(DEBUG_PCI) { \
+            fprintf(stderr, fmt, ## __VA_ARGS__); \
+        } \
+    } while(0)
+
 #define PCIE500_CFGADDR       0x0
 #define PCIE500_CFGDATA       0x4
 #define PCIE500_REG_BASE      0xC00