diff mbox

[26/43] unicore32: made printf always compile in debug output

Message ID CA+KKJYAZ7ZQ_SuwgJYiTiZSM=roGQgZhLoL4HM4YY-W4h6GVWw@mail.gmail.com
State New
Headers show

Commit Message

Danil Antonov April 1, 2017, 2 p.m. UTC
From 32ac7bdabbf1935a8a30f606aa3263461117e7d0 Mon Sep 17 00:00:00 2001
From: Danil Antonov <g.danil.anto@gmail.com>
Date: Wed, 29 Mar 2017 12:36:57 +0300
Subject: [PATCH 26/43] unicore32: 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 <g.danil.anto@gmail.com>
---
 include/hw/unicore32/puv3.h | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/include/hw/unicore32/puv3.h b/include/hw/unicore32/puv3.h
index 5a4839f..e9e3ae6 100644
--- a/include/hw/unicore32/puv3.h
+++ b/include/hw/unicore32/puv3.h
@@ -41,10 +41,15 @@ 
 #define PUV3_IRQS_OST0          (26)

 /* All puv3_*.c use DPRINTF for debug. */
-#ifdef DEBUG_PUV3
-#define DPRINTF(fmt, ...) printf("%s: " fmt , __func__, ## __VA_ARGS__)
-#else
-#define DPRINTF(fmt, ...) do {} while (0)
-#endif
+
+#ifndef DEBUG_PUV3
+#define DEBUG_PUV3 0
+#endif
+
+#define DPRINTF(fmt, ...) do {                                 \
+    if (DEBUG_PUV3) {                                          \
+        fprintf(stderr, "%s: " fmt, __func__, ## __VA_ARGS__); \
+    }                                                          \
+} while (0);

 #endif /* QEMU_HW_PUV3_H */