qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gonglei <arei.gonglei@huawei.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: "qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
	"mst@redhat.com" <mst@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"Huangpeng (Peter)" <peter.huangpeng@huawei.com>
Subject: Re: [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch
Date: Thu, 13 Nov 2014 19:49:40 +0800	[thread overview]
Message-ID: <54649AD4.8040806@huawei.com> (raw)
In-Reply-To: <20141113112734.GN7462@stefanha-thinkpad.redhat.com>

On 2014/11/13 19:27, Stefan Hajnoczi wrote:

> On Thu, Nov 13, 2014 at 10:39:32AM +0800, arei.gonglei@huawei.com wrote:
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>>  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.
> 

Yes.

> 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.
> 

Hum, trace events is great! :)

Best regards,
-Gonglei

  reply	other threads:[~2014-11-13 11:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-13  2:39 [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch arei.gonglei
2014-11-13 11:23 ` Stefan Hajnoczi
2014-11-13 11:27 ` Stefan Hajnoczi
2014-11-13 11:49   ` Gonglei [this message]
2014-12-10  8:20 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54649AD4.8040806@huawei.com \
    --to=arei.gonglei@huawei.com \
    --cc=mst@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).