diff mbox

[24/43] migration: made printf always compile in debug output

Message ID CA+KKJYDrS0c0GoxctMGG2cg+8C9Jqg_2LoiRVy59J8rnXiZYPA@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Danil Antonov April 1, 2017, 1:58 p.m. UTC
From e5719e802fcd1d1b426d687524ed46f10d044941 Mon Sep 17 00:00:00 2001
From: Danil Antonov <g.danil.anto@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.anto@gmail.com>
---
 migration/block.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Juan Quintela April 3, 2017, 6:35 a.m. UTC | #1
Danil Antonov <g.danil.anto@gmail.com> wrote:
> From e5719e802fcd1d1b426d687524ed46f10d044941 Mon Sep 17 00:00:00 2001
> From: Danil Antonov <g.danil.anto@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.anto@gmail.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>
diff mbox

Patch

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.  */