diff mbox

[07/14] scsi: Convert conditional compilation of debug printfs to regular ifs

Message ID 1398673575-7773-7-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/scsi/lsi53c895a.c   |   26 +++++++++++++++++---------
 hw/scsi/scsi-generic.c |   16 ++++++++++------
 hw/scsi/spapr_vscsi.c  |   17 ++++++++++-------
 3 files changed, 37 insertions(+), 22 deletions(-)
diff mbox

Patch

diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index cb30414..5b0ca47 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -20,19 +20,27 @@ 
 #include "hw/scsi/scsi.h"
 #include "sysemu/dma.h"
 
-//#define DEBUG_LSI
+//#define DEBUG_LSI 1
 //#define DEBUG_LSI_REG
 
-#ifdef DEBUG_LSI
+#ifndef DEBUG_LSI
+#define DEBUG_LSI 0
+#endif
+
 #define DPRINTF(fmt, ...) \
-do { printf("lsi_scsi: " fmt , ## __VA_ARGS__); } while (0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
-#else
-#define DPRINTF(fmt, ...) do {} while(0)
+    do { \
+        if(DEBUG_LSI) { \
+            printf("lsi_scsi: " fmt , ## __VA_ARGS__); \
+        } \
+    } while (0)
+
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__);} while (0)
-#endif
+    do { \
+        fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__); \
+        if(DEBUG_LSI) { \
+            exit(1); \
+        } \
+    } while (0)
 
 #define LSI_MAX_DEVS 7
 
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 8d92e0d..4bc65fe 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -18,15 +18,19 @@ 
 
 #ifdef __linux__
 
-//#define DEBUG_SCSI
+//#define DEBUG_SCSI 1
 
-#ifdef DEBUG_SCSI
-#define DPRINTF(fmt, ...) \
-do { printf("scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) do {} while(0)
+#ifndef DEBUG_SCSI
+#define DEBUG_SCSI 0
 #endif
 
+#define DPRINTF(fmt, ...) \
+    do { \
+        if(DEBUG_SCSI) { \
+            printf("scsi-generic: " fmt, ## __VA_ARGS__); \
+        } \
+    } while (0)
+
 #define BADF(fmt, ...) \
 do { fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
 
diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
index d4ada4f..f2e19ba 100644
--- a/hw/scsi/spapr_vscsi.c
+++ b/hw/scsi/spapr_vscsi.c
@@ -42,16 +42,19 @@ 
 
 #include <libfdt.h>
 
-/*#define DEBUG_VSCSI*/
+/*#define DEBUG_VSCSI 1*/
 
-#ifdef DEBUG_VSCSI
-#define DPRINTF(fmt, ...) \
-    do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) \
-    do { } while (0)
+#ifndef DEBUG_VSCSI
+#define DEBUG_VSCSI 0
 #endif
 
+#define DPRINTF(fmt, ...) \
+    do { \
+        if(DEBUG_VSCSI) { \
+            fprintf(stderr, fmt, ## __VA_ARGS__); \
+        } \
+    } while (0)
+
 /*
  * Virtual SCSI device
  */