[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 30/43] block: made printf always compile in debug ou
From: |
Danil Antonov |
Subject: |
[Qemu-devel] [PATCH 30/43] block: made printf always compile in debug output |
Date: |
Sat, 1 Apr 2017 17:02:23 +0300 |
>From 63139dc0a7e3b5c8caa1ecf6fbe900372fddeba0 Mon Sep 17 00:00:00 2001
From: Danil Antonov <address@hidden>
Date: Wed, 29 Mar 2017 12:39:12 +0300
Subject: [PATCH 30/43] block: 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/block/pflash_cfi01.c | 18 +++++++++---------
hw/block/pflash_cfi02.c | 19 +++++++++++--------
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 594d4cf..6e07ad7 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -55,15 +55,15 @@ do { \
exit(1); \
} while(0)
-/* #define PFLASH_DEBUG */
-#ifdef PFLASH_DEBUG
-#define DPRINTF(fmt, ...) \
-do { \
- fprintf(stderr, "PFLASH: " fmt , ## __VA_ARGS__); \
-} while (0)
-#else
-#define DPRINTF(fmt, ...) do { } while (0)
-#endif
+#ifndef PFLASH_DEBUG
+#define PFLASH_DEBUG 0
+#endif
+
+#define DPRINTF(fmt, ...) do { \
+ if (PFLASH_DEBUG) { \
+ fprintf(stderr, "PFLASH: " fmt, ## __VA_ARGS__); \
+ } \
+} while (0);
#define CFI_PFLASH01(obj) OBJECT_CHECK(pflash_t, (obj), TYPE_CFI_PFLASH01)
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index e6c5c6c..be35bca 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -46,14 +46,17 @@
#include "hw/sysbus.h"
//#define PFLASH_DEBUG
-#ifdef PFLASH_DEBUG
-#define DPRINTF(fmt, ...) \
-do { \
- fprintf(stderr, "PFLASH: " fmt , ## __VA_ARGS__); \
-} while (0)
-#else
-#define DPRINTF(fmt, ...) do { } while (0)
-#endif
+
+#ifndef PFLASH_DEBUG
+#define PFLASH_DEBUG 0
+#endif
+
+#define DPRINTF(fmt, ...) do { \
+ if (PFLASH_DEBUG) { \
+ fprintf(stderr, "PFLASH: " fmt, ## __VA_ARGS__); \
+ } \
+} while (0);
+
#define PFLASH_LAZY_ROMD_THRESHOLD 42
--
2.8.0.rc3
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH 30/43] block: made printf always compile in debug output,
Danil Antonov <=