qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 27/43] vfio: made printf always compile in debug out


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

>From c986c5a54a394feadfd885d41848f28d11fec40f Mon Sep 17 00:00:00 2001
From: Danil Antonov <address@hidden>
Date: Wed, 29 Mar 2017 12:37:26 +0300
Subject: [PATCH 27/43] vfio: 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>
---
 include/hw/vfio/vfio-common.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index c582de1..3d3cc89 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -33,14 +33,15 @@
 #define ERR_PREFIX "vfio error: %s: "
 #define WARN_PREFIX "vfio warning: %s: "

-/*#define DEBUG_VFIO*/
-#ifdef DEBUG_VFIO
-#define DPRINTF(fmt, ...) \
-    do { fprintf(stderr, "vfio: " fmt, ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) \
-    do { } while (0)
-#endif
+#ifndef DEBUG_VFIO
+#define DEBUG_VFIO 0
+#endif
+
+#define DPRINTF(fmt, ...) do {                         \
+    if (DEBUG_VFIO) {                                  \
+        fprintf(stderr, "vfio: " fmt, ## __VA_ARGS__); \
+    }                                                  \
+} while (0);

 enum {
     VFIO_DEVICE_TYPE_PCI = 0,
-- 
2.8.0.rc3


reply via email to

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