>From ef4e9e576ae80c227d06721284bd49b699e71c71 Mon Sep 17 00:00:00 2001 From: Danil Antonov <g.danil.a...@gmail.com> Date: Wed, 29 Mar 2017 12:41:59 +0300 Subject: [PATCH 37/43] audio: 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> --- hw/audio/lm4549.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/audio/lm4549.c b/hw/audio/lm4549.c index a46f230..962db8e 100644 --- a/hw/audio/lm4549.c +++ b/hw/audio/lm4549.c @@ -26,13 +26,17 @@ #define LM4549_DUMP_DAC_INPUT 1 #endif -#ifdef LM4549_DEBUG -#define DPRINTF(fmt, ...) \ -do { printf("lm4549: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) do {} while (0) +#ifndef LM4549_DEBUG +#define LM4549_DEBUG 0 #endif +#define DPRINTF(fmt, ...) \ + do { \ + if (LM4549_DEBUG) { \ + fprintf(stderr, "lm4549: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) + #if defined(LM4549_DUMP_DAC_INPUT) static FILE *fp_dac_input; #endif @@ -159,7 +163,7 @@ uint32_t lm4549_read(lm4549_state *s, hwaddr offset) assert(offset < 128); value = regfile[offset]; - DPRINTF("read [0x%02x] = 0x%04x\n", offset, value); + DPRINTF("read [0x%02x] = 0x%04x\n", (int) offset, value); return value; } @@ -170,7 +174,7 @@ void lm4549_write(lm4549_state *s, uint16_t *regfile = s->regfile; assert(offset < 128); - DPRINTF("write [0x%02x] = 0x%04x\n", offset, value); + DPRINTF("write [0x%02x] = 0x%04x\n", (int) offset, value); switch (offset) { case LM4549_Reset: -- 2.8.0.rc3