>From e7a576c46bcdaeb49c1c4fdbb59d38944df340ae Mon Sep 17 00:00:00 2001 From: Danil Antonov <g.danil.a...@gmail.com> Date: Wed, 29 Mar 2017 02:14:49 +0300 Subject: [PATCH 06/43] unicore32: 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> --- target/unicore32/helper.c | 16 +++++++++------- target/unicore32/softmmu.c | 14 ++++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/target/unicore32/helper.c b/target/unicore32/helper.c index f9239dc..5df8de0 100644 --- a/target/unicore32/helper.c +++ b/target/unicore32/helper.c @@ -19,13 +19,15 @@ #include "ui/console.h" #endif -#undef DEBUG_UC32 - -#ifdef DEBUG_UC32 -#define DPRINTF(fmt, ...) printf("%s: " fmt , __func__, ## __VA_ARGS__) -#else -#define DPRINTF(fmt, ...) do {} while (0) -#endif +#ifndef DEBUG_UC32 +#define DEBUG_UC32 0 +#endif + +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_UC32) { \ + fprintf(stderr, "%s: " fmt, __func__, ## __VA_ARGS__); \ + } \ +} while (0); UniCore32CPU *uc32_cpu_init(const char *cpu_model) { diff --git a/target/unicore32/softmmu.c b/target/unicore32/softmmu.c index e7152e7..173875b 100644 --- a/target/unicore32/softmmu.c +++ b/target/unicore32/softmmu.c @@ -16,13 +16,15 @@ #include "cpu.h" #include "exec/exec-all.h" -#undef DEBUG_UC32 +#ifndef DEBUG_UC32 +#define DEBUG_UC32 0 +#endif -#ifdef DEBUG_UC32 -#define DPRINTF(fmt, ...) printf("%s: " fmt , __func__, ## __VA_ARGS__) -#else -#define DPRINTF(fmt, ...) do {} while (0) -#endif +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_UC32) { \ + fprintf(stderr, "%s: " fmt, __func__, ## __VA_ARGS__); \ + } \ +} while (0); #define SUPERPAGE_SIZE (1 << 22) #define UC32_PAGETABLE_READ (1 << 8) -- 2.8.0.rc3