diff mbox series

[4/4] i386/kvm: make printf always compile in debug output

Message ID 5F9919B3.9070605@huawei.com (mailing list archive)
State New, archived
Headers show
Series [1/4] configure: Add a --enable-debug-kvm option to configure | expand

Commit Message

Alex Chen Oct. 28, 2020, 7:11 a.m. UTC
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: AlexChen <alex.chen@huawei.com>
---
 target/i386/kvm.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 3e9344aed5..64492cb851 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -50,14 +50,13 @@ 
 #include "exec/memattrs.h"
 #include "trace.h"

-#ifdef CONFIG_DEBUG_KVM
-#define DPRINTF(fmt, ...) \
-    do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) \
-    do { } while (0)
+#ifndef CONFIG_DEBUG_KVM
+#define CONFIG_DEBUG_KVM  0
 #endif

+#define DPRINTF(fmt, ...) \
+    do { if (CONFIG_DEBUG_KVM) { fprintf(stderr, fmt, ## __VA_ARGS__); } } while (0)
+
 /* From arch/x86/kvm/lapic.h */
 #define KVM_APIC_BUS_CYCLE_NS       1
 #define KVM_APIC_BUS_FREQUENCY      (1000000000ULL / KVM_APIC_BUS_CYCLE_NS)