>From 8127ae68568b3c6876a5ee58a74e5ef0439f548a Mon Sep 17 00:00:00 2001 From: Danil Antonov <g.danil.a...@gmail.com> Date: Wed, 29 Mar 2017 01:59:37 +0300 Subject: [PATCH 01/43] acpi: 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/acpi/pcihp.c | 15 +++++++++------ hw/acpi/piix4.c | 16 +++++++++------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 2b0f3e1..bf880c1 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -39,13 +39,16 @@ #include "qom/qom-qobject.h" #include "qapi/qmp/qint.h" -//#define DEBUG -#ifdef DEBUG -# define ACPI_PCIHP_DPRINTF(format, ...) printf(format, ## __VA_ARGS__) -#else -# define ACPI_PCIHP_DPRINTF(format, ...) do { } while (0) -#endif +#ifndef DEBUG +#define DEBUG 0 +#endif + +#define ACPI_PCIHP_DPRINTF(fmt, ...) do { \ + if (DEBUG) { \ + fprintf(stderr, fmt, ## __VA_ARGS__); \ + } \ +} while (0); #define ACPI_PCIHP_ADDR 0xae00 #define ACPI_PCIHP_SIZE 0x0014 diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index a553a7e..34e85b4 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -42,13 +42,15 @@ #include "hw/xen/xen.h" #include "qom/cpu.h" -//#define DEBUG - -#ifdef DEBUG -# define PIIX4_DPRINTF(format, ...) printf(format, ## __VA_ARGS__) -#else -# define PIIX4_DPRINTF(format, ...) do { } while (0) -#endif +#ifndef DEBUG +#define DEBUG 0 +#endif + +#define PIIX4_DPRINTF(fmt, ...) do { \ + if (DEBUG) { \ + fprintf(stderr, fmt, ## __VA_ARGS__); \ + } \ +} while (0); #define GPE_BASE 0xafe0 #define GPE_LEN 4 -- 2.8.0.rc3