[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/43] scsi: made printf always compile in debug out
From: |
Danil Antonov |
Subject: |
[Qemu-devel] [PATCH 11/43] scsi: made printf always compile in debug output |
Date: |
Sat, 1 Apr 2017 16:46:43 +0300 |
>From 48b18f304de1761128e8cccbb517ddad4346c824 Mon Sep 17 00:00:00 2001
From: Danil Antonov <address@hidden>
Date: Wed, 29 Mar 2017 12:26:43 +0300
Subject: [PATCH 11/43] scsi: 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 <address@hidden>
---
hw/scsi/lsi53c895a.c | 26 ++++++++++++++++----------
hw/scsi/scsi-disk.c | 17 ++++++++++-------
hw/scsi/scsi-generic.c | 17 +++++++++--------
3 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index 595c260..379db4b 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -24,16 +24,22 @@
//#define DEBUG_LSI
//#define DEBUG_LSI_REG
-#ifdef DEBUG_LSI
-#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)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__);} while (0)
-#endif
+#ifndef DEBUG_LSI
+#define DEBUG_LSI 0
+#endif
+
+#define DPRINTF(fmt, ...) do { \
+ if (DEBUG_LSI) { \
+ fprintf(stderr, "lsi_scsi: " fmt , ## __VA_ARGS__); \
+ } \
+} while (0);
+
+#define BADF(fmt, ...) do { \
+ fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__); \
+ if (DEBUG_LSI) { \
+ exit(1); \
+ } \
+} while (0);
static const char *names[] = {
"SCNTL0", "SCNTL1", "SCNTL2", "SCNTL3", "SCID", "SXFER", "SDID",
"GPREG",
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index a53f058..33213df 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -19,14 +19,17 @@
* the host adapter emulator.
*/
-//#define DEBUG_SCSI
-#ifdef DEBUG_SCSI
-#define DPRINTF(fmt, ...) \
-do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) do {} while(0)
-#endif
+#ifndef DEBUG_SCSI
+#define DEBUG_SCSI 0
+#endif
+
+#define DPRINTF(fmt, ...) do { \
+ if (DEBUG_SCSI) { \
+ fprintf(stderr, "scsi-disk: " fmt , ## __VA_ARGS__); \
+ } \
+} while (0);
+
#include "qemu/osdep.h"
#include "qapi/error.h"
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index a55ff87..dcd3c08 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -21,14 +21,15 @@
#ifdef __linux__
-//#define DEBUG_SCSI
-
-#ifdef DEBUG_SCSI
-#define DPRINTF(fmt, ...) \
-do { printf("scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) do {} while(0)
-#endif
+#ifndef DEBUG_SCSI
+#define DEBUG_SCSI 0
+#endif
+
+#define DPRINTF(fmt, ...) do { \
+ if (DEBUG_SCSI) { \
+ fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__); \
+ } \
+} while (0);
#define BADF(fmt, ...) \
do { fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
--
2.8.0.rc3
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH 11/43] scsi: made printf always compile in debug output,
Danil Antonov <=