[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/43] arm: made printf always compile in debug outp
From: |
Danil Antonov |
Subject: |
[Qemu-devel] [PATCH 02/43] arm: made printf always compile in debug output |
Date: |
Sat, 1 Apr 2017 16:32:26 +0300 |
>From 1671b92e5a4a59d5e38ce754d1d0dde2401c8236 Mon Sep 17 00:00:00 2001
From: Danil Antonov <address@hidden>
Date: Wed, 29 Mar 2017 02:09:33 +0300
Subject: [PATCH 02/43] arm: 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 <address@hidden>
---
hw/arm/strongarm.c | 17 +++++++++++------
hw/arm/z2.c | 16 ++++++++++------
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c
index 3311cc3..88368ac 100644
--- a/hw/arm/strongarm.c
+++ b/hw/arm/strongarm.c
@@ -59,11 +59,16 @@
- Enhance UART with modem signals
*/
-#ifdef DEBUG
-# define DPRINTF(format, ...) printf(format , ## __VA_ARGS__)
-#else
-# define DPRINTF(format, ...) do { } while (0)
-#endif
+#ifndef DEBUG
+#define DEBUG 0
+#endif
+
+#define DPRINTF(fmt, ...) \
+ do { \
+ if (DEBUG) { \
+ fprintf(stderr, fmt, ## __VA_ARGS__); \
+ } \
+ } while (0)
static struct {
hwaddr io_base;
@@ -1022,7 +1027,7 @@ static void
strongarm_uart_update_parameters(StrongARMUARTState
*s)
s->char_transmit_time = (NANOSECONDS_PER_SECOND / speed) * frame_size;
qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
- DPRINTF(stderr, "%s speed=%d parity=%c data=%d stop=%d\n",
s->chr->label,
+ DPRINTF("%s speed=%d parity=%c data=%d stop=%d\n", s->chr.chr->label,
speed, parity, data_bits, stop_bits);
}
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 1607cbd..1ee8ed9 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -27,12 +27,16 @@
#include "exec/address-spaces.h"
#include "sysemu/qtest.h"
-#ifdef DEBUG_Z2
-#define DPRINTF(fmt, ...) \
- printf(fmt, ## __VA_ARGS__)
-#else
-#define DPRINTF(fmt, ...)
-#endif
+#ifndef DEBUG_Z2
+#define DEBUG_Z2 0
+#endif
+
+#define DPRINTF(fmt, ...) \
+ do { \
+ if (DEBUG_Z2) { \
+ fprintf(stderr, "z2: " fmt, ## __VA_ARGS__); \
+ } \
+ } while (0)
static const struct keymap map[0x100] = {
[0 ... 0xff] = { -1, -1 },
--
2.8.0.rc3
- [Qemu-devel] [PATCH 02/43] arm: made printf always compile in debug output,
Danil Antonov <=