>From f0ac5a35af1c521bb8f87720ec7f82a9452e38a4 Mon Sep 17 00:00:00 2001 From: Danil Antonov <g.danil.a...@gmail.com> Date: Wed, 29 Mar 2017 12:43:45 +0300 Subject: [PATCH 41/43] nvram: 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/nvram/mac_nvram.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c index aef80e6..e152203 100644 --- a/hw/nvram/mac_nvram.c +++ b/hw/nvram/mac_nvram.c @@ -32,12 +32,16 @@ /* debug NVR */ //#define DEBUG_NVR -#ifdef DEBUG_NVR -#define NVR_DPRINTF(fmt, ...) \ - do { printf("NVR: " fmt , ## __VA_ARGS__); } while (0) -#else -#define NVR_DPRINTF(fmt, ...) -#endif +#ifndef DEBUG_NVR +#define DEBUG_NVR 0 +#endif + +#define NVR_DPRINTF(fmt, ...) \ + do { \ + if (DEBUG_NVR) { \ + fprintf(stderr, "NVR: " fmt, ## __VA_ARGS__); \ + } \ + } while (0) #define DEF_SYSTEM_SIZE 0xc10 -- 2.8.0.rc3