From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XosYx-0002bs-13 for qemu-devel@nongnu.org; Thu, 13 Nov 2014 06:27:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XosYr-0001hk-Jf for qemu-devel@nongnu.org; Thu, 13 Nov 2014 06:27:42 -0500 Date: Thu, 13 Nov 2014 11:27:34 +0000 From: Stefan Hajnoczi Message-ID: <20141113112734.GN7462@stefanha-thinkpad.redhat.com> References: <1415846372-12756-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sy9WyBOsCRoUO165" Content-Disposition: inline In-Reply-To: <1415846372-12756-1-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com Cc: qemu-trivial@nongnu.org, mst@redhat.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com --sy9WyBOsCRoUO165 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 13, 2014 at 10:39:32AM +0800, arei.gonglei@huawei.com wrote: > From: Gonglei >=20 > Signed-off-by: Gonglei > --- > hw/virtio/virtio-bus.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > 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 =3D virtio_bus_get_device(bus); > =20 > - 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=3Dstderr and all trace_*() calls are turned into fprintf(stderr). The cool thing about trace events is that they are available in production too. Stefan --sy9WyBOsCRoUO165 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUZJWmAAoJEJykq7OBq3PI2N8IAKnlYY5x3/WY0aTWW+s05gHr J7Hcngo2YfRWvZK2mmqfEY80gF11GSqLTRAkU87RXWk4pD9FQ4Y9VZs6hGYMAPnZ HXoANH+UPO/U9v6KRcDK36OjZN0UwZmhivvsICEhxANq+8SkbuhOUlZll5AQfllp o/QWowhfCpP4Vsz7QX0XhIPXF9+lGo9WvITlEaT8vHrgFNhxDwhUmwqFtH8OIEMy Vyk7rmGx+4UyGo7Lif1iPmnVt6rGsCEI5hsKzrTHVVKabjVdTChl0UWMnnKRuGpS gZdaQpKhI78oprzFGLLPnJiIDVtaZ2USiEMh1/4Bd445hECT65pa6Mx7MbT9J+8= =oOyx -----END PGP SIGNATURE----- --sy9WyBOsCRoUO165--