qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 08/14] sd: Convert conditional compilation of debug


From: Marc Marí
Subject: [Qemu-devel] [PATCH 08/14] sd: Convert conditional compilation of debug printfs to regular ifs
Date: Mon, 28 Apr 2014 10:26:09 +0200

From: Marc Marí <address@hidden>

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

Signed-off-by: Marc Marí <address@hidden>
---
 hw/sd/sd.c     |   14 +++++++++-----
 hw/sd/ssi-sd.c |   24 ++++++++++++++++--------
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 4502ad1..641a53e 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -36,13 +36,17 @@
 
 //#define DEBUG_SD 1
 
-#ifdef DEBUG_SD
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, "SD: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) do {} while(0)
+#ifndef DEBUG_SD
+#define DEBUG_SD 0
 #endif
 
+#define DPRINTF(fmt, ...) \
+    do { \
+        if(DEBUG_SD) { \
+            fprintf(stderr, "SD: " fmt , ## __VA_ARGS__); \
+        } \
+    } while (0)
+
 #define ACMD41_ENQUIRY_MASK 0x00ffffff
 
 typedef enum {
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index 3273c8a..0855ec0 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -16,16 +16,24 @@
 
 //#define DEBUG_SSI_SD 1
 
-#ifdef DEBUG_SSI_SD
+#ifndef DEBUG_SSI_SD
+#define DEBUG_SSI_SD 0
+#endif
+
 #define DPRINTF(fmt, ...) \
-do { printf("ssi_sd: " fmt , ## __VA_ARGS__); } while (0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "ssi_sd: error: " fmt , ## __VA_ARGS__); exit(1);} while 
(0)
-#else
-#define DPRINTF(fmt, ...) do {} while(0)
+    do { \
+        if(DEBUG_SSI_SD) { \
+            printf("ssi_sd: " fmt , ## __VA_ARGS__); \
+        } \
+    } while (0)
+
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "ssi_sd: error: " fmt , ## __VA_ARGS__);} while (0)
-#endif
+    do { \
+        fprintf(stderr, "ssi_sd: error: " fmt , ## __VA_ARGS__); \
+        if(DEBUG_SSI_SD) { \
+            exit(1); \
+        } \
+    } while (0)
 
 typedef enum {
     SSI_SD_CMD,
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]