qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 41/43] nvram: made printf always compile in debug ou


From: Danil Antonov
Subject: [Qemu-devel] [PATCH 41/43] nvram: made printf always compile in debug output
Date: Sat, 1 Apr 2017 17:08:50 +0300

>From f0ac5a35af1c521bb8f87720ec7f82a9452e38a4 Mon Sep 17 00:00:00 2001
From: Danil Antonov <address@hidden>
Date: Wed, 29 Mar 2017 12:43:45 +0300
Subject: [PATCH 41/43] nvram: 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/nvram/mac_nvram.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index aef80e6..e152203 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -32,12 +32,16 @@
 /* debug NVR */
 //#define DEBUG_NVR

-#ifdef DEBUG_NVR
-#define NVR_DPRINTF(fmt, ...)                                   \
-    do { printf("NVR: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define NVR_DPRINTF(fmt, ...)
-#endif
+#ifndef DEBUG_NVR
+#define DEBUG_NVR 0
+#endif
+
+#define NVR_DPRINTF(fmt, ...)                             \
+    do {                                                  \
+        if (DEBUG_NVR) {                                  \
+            fprintf(stderr, "NVR: " fmt, ## __VA_ARGS__); \
+        }                                                 \
+    } while (0)

 #define DEF_SYSTEM_SIZE 0xc10

-- 
2.8.0.rc3


reply via email to

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