>From e5719e802fcd1d1b426d687524ed46f10d044941 Mon Sep 17 00:00:00 2001 From: Danil Antonov <g.danil.a...@gmail.com> Date: Wed, 29 Mar 2017 12:35:10 +0300 Subject: [PATCH 24/43] migration: 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> --- migration/block.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/migration/block.c b/migration/block.c index 7734ff7..a5b4e49 100644 --- a/migration/block.c +++ b/migration/block.c @@ -42,13 +42,15 @@ //#define DEBUG_BLK_MIGRATION -#ifdef DEBUG_BLK_MIGRATION -#define DPRINTF(fmt, ...) \ - do { printf("blk_migration: " fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) -#endif +#ifndef DEBUG_BLK_MIGRATION +#define DEBUG_BLK_MIGRATION 0 +#endif + +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_BLK_MIGRATION) { \ + fprintf(stderr, "blk_migration: " fmt, ## __VA_ARGS__); \ + } \ +} while (0); typedef struct BlkMigDevState { /* Written during setup phase. Can be read without a lock. */ -- 2.8.0.rc3