diff mbox

[02/14] i386: Convert conditional compilation of debug printfs to regular ifs

Message ID 1398673575-7773-2-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/i386/kvm/pci-assign.c |   18 ++++++++++--------
 hw/i386/multiboot.c      |   15 ++++++++++-----
 2 files changed, 20 insertions(+), 13 deletions(-)
diff mbox

Patch

diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index a825871..83f2151 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -48,17 +48,19 @@ 
 #define IORESOURCE_PREFETCH 0x00002000  /* No side effects */
 #define IORESOURCE_MEM_64   0x00100000
 
-//#define DEVICE_ASSIGNMENT_DEBUG
+//#define DEVICE_ASSIGNMENT_DEBUG 1
 
-#ifdef DEVICE_ASSIGNMENT_DEBUG
-#define DEBUG(fmt, ...)                                       \
-    do {                                                      \
-        fprintf(stderr, "%s: " fmt, __func__ , __VA_ARGS__);  \
-    } while (0)
-#else
-#define DEBUG(fmt, ...)
+#ifndef DEVICE_ASSIGNMENT_DEBUG
+#define DEVICE_ASSIGNMENT_DEBUG 0
 #endif
 
+#define DEBUG(fmt, ...)                                           \
+    do {                                                          \
+        if(DEVICE_ASSIGNMENT_DEBUG) {                             \
+            fprintf(stderr, "%s: " fmt, __func__ , __VA_ARGS__);  \
+        }                                                         \
+    } while (0)
+
 typedef struct PCIRegion {
     int type;           /* Memory or port I/O */
     int valid;
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
index 985ca1e..3acab60 100644
--- a/hw/i386/multiboot.c
+++ b/hw/i386/multiboot.c
@@ -30,14 +30,19 @@ 
 #include "sysemu/sysemu.h"
 
 /* Show multiboot debug output */
-//#define DEBUG_MULTIBOOT
+//#define DEBUG_MULTIBOOT 1
 
-#ifdef DEBUG_MULTIBOOT
-#define mb_debug(a...) fprintf(stderr, ## a)
-#else
-#define mb_debug(a...)
+#ifndef DEBUG_MULTIBOOT
+#define DEBUG_MULTIBOOT 0
 #endif
 
+#define mb_debug(a...) \
+    do { \
+        if(DEBUG_MULTIBOOT) { \
+            fprintf(stderr, ## a); \
+        } \
+    } while(0)
+
 #define MULTIBOOT_STRUCT_ADDR 0x9000
 
 #if MULTIBOOT_STRUCT_ADDR > 0xf0000