>From 825d7eda5d2900ef7eda37eeebf2b50ea445d50b Mon Sep 17 00:00:00 2001 From: Danil Antonov <g.danil.a...@gmail.com> Date: Wed, 29 Mar 2017 12:38:23 +0300 Subject: [PATCH 28/43] sparc64: 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/sparc64/sparc64.c | 36 +++++++++++++++++++----------------- hw/sparc64/sun4u.c | 16 +++++++++------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/hw/sparc64/sparc64.c b/hw/sparc64/sparc64.c index 4e4fdab..2f1136f 100644 --- a/hw/sparc64/sparc64.c +++ b/hw/sparc64/sparc64.c @@ -29,23 +29,25 @@ #include "hw/sparc/sparc64.h" #include "qemu/timer.h" - -//#define DEBUG_IRQ -//#define DEBUG_TIMER - -#ifdef DEBUG_IRQ -#define CPUIRQ_DPRINTF(fmt, ...) \ - do { printf("CPUIRQ: " fmt , ## __VA_ARGS__); } while (0) -#else -#define CPUIRQ_DPRINTF(fmt, ...) -#endif - -#ifdef DEBUG_TIMER -#define TIMER_DPRINTF(fmt, ...) \ - do { printf("TIMER: " fmt , ## __VA_ARGS__); } while (0) -#else -#define TIMER_DPRINTF(fmt, ...) -#endif +#ifndef DEBUG_IRQ +#define DEBUG_IRQ 0 +#endif + +#ifndef DEBUG_TIMER +#define DEBUG_TIMER 0 +#endif + +#define CPUIRQ_DPRINTF(fmt, ...) do { \ + if (DEBUG_IRQ) { \ + fprintf(stderr, "CPUIRQ: " fmt , ## __VA_ARGS__); \ + } \ +} while (0); + +#define TIMER_DPRINTF(fmt, ...) do { \ + if (DEBUG_TIMER) { \ + fprintf(stderr, "TIMER: " fmt , ## __VA_ARGS__); \ + } \ +} while (0); #define TICK_MAX 0x7fffffffffffffffULL diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index d347b66..c27b738 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -46,14 +46,16 @@ #include "elf.h" #include "qemu/cutils.h" -//#define DEBUG_EBUS -#ifdef DEBUG_EBUS -#define EBUS_DPRINTF(fmt, ...) \ - do { printf("EBUS: " fmt , ## __VA_ARGS__); } while (0) -#else -#define EBUS_DPRINTF(fmt, ...) -#endif +#ifndef DEBUG_EBUS +#define DEBUG_EBUS 0 +#endif + +#define EBUS_DPRINTF(fmt, ...) do { \ + if (DEBUG_EBUS) { \ + fprintf(stderr, "EBUS: " fmt , ## __VA_ARGS__); \ + } \ +} while (0); #define KERNEL_LOAD_ADDR 0x00404000 #define CMDLINE_ADDR 0x003ff000 -- 2.8.0.rc3