diff mbox

[40/43] mips: made printf always compile in debug output

Message ID CA+KKJYDE0D8V6P_vaA9=zfxr2gza_fW4n7W2B4aP3cSq+PcU-w@mail.gmail.com
State New
Headers show

Commit Message

Danil Antonov April 1, 2017, 2:08 p.m. UTC
From fafbd66ef7cd5e2295a5c14e24a6ec1520ca79f4 Mon Sep 17 00:00:00 2001
From: Danil Antonov <g.danil.anto@gmail.com>
Date: Wed, 29 Mar 2017 12:43:28 +0300
Subject: [PATCH 40/43] mips: 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>
---
 hw/mips/gt64xxx_pci.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c
index 4811843..adb64ff 100644
--- a/hw/mips/gt64xxx_pci.c
+++ b/hw/mips/gt64xxx_pci.c
@@ -30,13 +30,16 @@ 
 #include "hw/i386/pc.h"
 #include "exec/address-spaces.h"

-//#define DEBUG

-#ifdef DEBUG
-#define DPRINTF(fmt, ...) fprintf(stderr, "%s: " fmt, __FUNCTION__,
##__VA_ARGS__)
-#else
-#define DPRINTF(fmt, ...)
-#endif
+#ifndef DEBUG
+#define DEBUG 0
+#endif
+
+#define DPRINTF(fmt, ...) do {                                    \
+    if (DEBUG) {                                                  \
+        fprintf(stderr, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__); \
+    }                                                             \
+} while (0);

 #define GT_REGS            (0x1000 >> 2)