From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqobX-0007Rr-CV for qemu-devel@nongnu.org; Fri, 08 May 2015 16:10:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqobW-0004hO-8v for qemu-devel@nongnu.org; Fri, 08 May 2015 16:10:39 -0400 Message-ID: <554D1837.10505@redhat.com> Date: Fri, 08 May 2015 14:10:31 -0600 From: Eric Blake MIME-Version: 1.0 References: <1431107242-31947-1-git-send-email-dimara@arrikto.com> <1431107242-31947-4-git-send-email-dimara@arrikto.com> In-Reply-To: <1431107242-31947-4-git-send-email-dimara@arrikto.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jFkDdffFEq03qx39k0GqHKJWhdOR3I9qL" Subject: Re: [Qemu-devel] [PATCH v2 3/5] raw-posix: DPRINTF instead of DEBUG_BLOCK_PRINT List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dimitris Aragiorgis , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jFkDdffFEq03qx39k0GqHKJWhdOR3I9qL Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/08/2015 11:47 AM, Dimitris Aragiorgis wrote: > Building the QEMU tools fails if we #define DEBUG_BLOCK inside > block/raw-posix.c. Here instead of adding qemu-log.o in block-obj-y > so that DEBUG_BLOCK_PRINT can be used, we substitute the latter with > a simple DPRINTF(). >=20 > Signed-off-by: Dimitris Aragiorgis > --- > block/raw-posix.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) >=20 > diff --git a/block/raw-posix.c b/block/raw-posix.c > index 24b061f..fbccca8 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -97,11 +97,11 @@ > //#define DEBUG_FLOPPY > =20 > //#define DEBUG_BLOCK > -#if defined(DEBUG_BLOCK) > -#define DEBUG_BLOCK_PRINT(formatCstr, ...) do { if (qemu_log_enabled()= ) \ > - { qemu_log(formatCstr, ## __VA_ARGS__); qemu_log_flush(); } } whil= e (0) > + > +#ifdef DEBUG_BLOCK > +#define DPRINTF(fmt, ...) do { printf(fmt, ## __VA_ARGS__); } while (0= ) > #else > -#define DEBUG_BLOCK_PRINT(formatCstr, ...) > +#define DPRINTF(fmt, ...) do { } while (0) Please fix this to ensure that we avoid bit-rot even when debugging is not turned on. Something like: #ifdef DEBUG_BLOCK # define DEBUG_BLOCK_PRINT 1 #else # define DEBUG_BLOCK_PRINT 0 #endif #define DPRINTF(fmt, ...) \ do \ if (DEBUG_BLOCK_PRINT) { \ printf(fmt, ## __VA_ARGS__); \ while (0) that way, the compiler checks that the printf format arguments are valid while still optimizing out the if(0) code. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jFkDdffFEq03qx39k0GqHKJWhdOR3I9qL Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVTRg3AAoJEKeha0olJ0NqZK4H/jImnEkZoLx+yhN07uagh1LG IZB5ehhYCMHvrIHoTriCrrBcuos0JjDrd4RFFAWmrniVlWbB2HHrXKgh/AZRm9i9 1MJ6zlI0ZYY9Roo3BTFqZiBW2zSvEup3102USNdCfMMkG4QIeCH+p4qf0ofRctPQ /leSSHpQhuHYsr8bad1eXjTbew45ZlWoyPxvXndUrDQO+AK767Gli8jKpMwUfafv I6/mfK9FYArMzvMP1SoAzkwFV0MgzqBtXlBWSQtHic070pSpVSa6QN38L7cvXjwp 30Y1azihlt3Tata9+Fu6BvmbBvrEjaSZs067MoUZp86Duudk1RHtduCO8q80k+w= =nUTR -----END PGP SIGNATURE----- --jFkDdffFEq03qx39k0GqHKJWhdOR3I9qL--