diff mbox

[05/43] xen-mapcache: made printf always compile in debug

Message ID CA+KKJYBMk15mHZ3jNYVAwRmDy6Z65-5Jf__sDE6=FFZLwXx3Nw@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Danil Antonov April 1, 2017, 1:35 p.m. UTC
From 0e4a8a20c9c05e547d42be1b9ef868d12e7b43a9 Mon Sep 17 00:00:00 2001
From: Danil Antonov <g.danil.anto@gmail.com>
Date: Wed, 29 Mar 2017 02:14:06 +0300
Subject: [PATCH 05/43] xen-mapcache: 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>
---
 xen-mapcache.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/xen-mapcache.c b/xen-mapcache.c
index 1a96d2e..c2d1e6f 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -22,15 +22,15 @@ 
 #include "trace-root.h"


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

 #if HOST_LONG_BITS == 32
 #  define MCACHE_BUCKET_SHIFT 16