[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [Qemu-devel] [PATCH] virtio-bus: avoid breaking build
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-trivial] [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch |
Date: |
Thu, 13 Nov 2014 11:27:34 +0000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Thu, Nov 13, 2014 at 10:39:32AM +0800, address@hidden wrote:
> From: Gonglei <address@hidden>
>
> Signed-off-by: Gonglei <address@hidden>
> ---
> hw/virtio/virtio-bus.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
> index eb77019..dfd2d8c 100644
> --- a/hw/virtio/virtio-bus.c
> +++ b/hw/virtio/virtio-bus.c
> @@ -58,7 +58,7 @@ void virtio_bus_reset(VirtioBusState *bus)
> {
> VirtIODevice *vdev = virtio_bus_get_device(bus);
>
> - DPRINTF("%s: reset device.\n", qbus->name);
> + DPRINTF("%s: reset device.\n", BUS(bus)->name);
In general the problem with existing DPRINTF() macros is that they use
#ifdef. This leads to bitrot, such as this instance.
A better approach is:
#define DEBUG_FOO 0
#define DPRINTF(...) \
do { \
if (DEBUG_FOO) { \
fprintf(stderr, ...); \
} \
} while (0)
Now the compiler always checks the DPRINTF() code.
Trace events can be a good solution too. If you like stderr output,
build QEMU with ./configure --enable-trace-backend=stderr and all
trace_*() calls are turned into fprintf(stderr).
The cool thing about trace events is that they are available in
production too.
Stefan
pgpy0gj6Vygfd.pgp
Description: PGP signature