>From fc02b5cacabab0d1fc547167954abb7447bfef21 Mon Sep 17 00:00:00 2001 From: Danil Antonov <g.danil.a...@gmail.com> Date: Wed, 29 Mar 2017 12:34:38 +0300 Subject: [PATCH 23/43] page-cahe: 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.a...@gmail.com> --- page_cache.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/page_cache.c b/page_cache.c index 5f85787..783a9a4 100644 --- a/page_cache.c +++ b/page_cache.c @@ -18,13 +18,16 @@ #include "qemu/host-utils.h" #include "migration/page_cache.h" -#ifdef DEBUG_CACHE -#define DPRINTF(fmt, ...) \ - do { fprintf(stdout, "cache: " fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) -#endif + +#ifndef DEBUG_CACHE +#define DEBUG_CACHE 0 +#endif + +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_CACHE) { \ + fprintf(stderr, "cache: " fmt, ## __VA_ARGS__); \ + } \ +} while (0); /* the page in cache will not be replaced in two cycles */ #define CACHED_PAGE_LIFETIME 2 -- 2.8.0.rc3