From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YstlZ-0002NG-E4 for qemu-devel@nongnu.org; Thu, 14 May 2015 10:05:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YstlV-00067g-GB for qemu-devel@nongnu.org; Thu, 14 May 2015 10:05:37 -0400 Message-ID: <5554AB9F.8020008@redhat.com> Date: Thu, 14 May 2015 08:05:19 -0600 From: Eric Blake MIME-Version: 1.0 References: <1431601275-4586-1-git-send-email-dimara@arrikto.com> <1431601275-4586-4-git-send-email-dimara@arrikto.com> In-Reply-To: <1431601275-4586-4-git-send-email-dimara@arrikto.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="w4RenxxiGGtLHPFc0dA3PhnsQ36CsmWF1" Subject: Re: [Qemu-devel] [PATCH v3 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, stefanha@redhat.com, qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --w4RenxxiGGtLHPFc0dA3PhnsQ36CsmWF1 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/14/2015 05:01 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() (that does not cause bit-rot). >=20 > Signed-off-by: Dimitris Aragiorgis > --- > block/raw-posix.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) >=20 > +#define DPRINTF(fmt, ...) \ > +do { \ > + if (DEBUG_BLOCK_PRINT) \ > + printf(fmt, ## __VA_ARGS__); \ > +} while (0) Still missing {} for the if statement. [It might be nice to update scripts/checkpatch.pl to catch correct {} inside macros, but that's a project for a different day.] > @@ -1023,7 +1028,7 @@ static int xfs_write_zeroes(BDRVRawState *s, int6= 4_t offset, uint64_t bytes) > fl.l_len =3D bytes; > =20 > if (xfsctl(NULL, s->fd, XFS_IOC_ZERO_RANGE, &fl) < 0) { > - DEBUG_BLOCK_PRINT("cannot write zero range (%s)\n", strerror(e= rrno)); > + DPRINTF("cannot write zero range (%s)\n", strerror(errno)); > return -errno; > } Pre-existing bug - strerror() and/or DPRINTF() can clobber errno, so your return value may be destroyed. You'll have to save errno into a temporary variable prior to DPRINTF, and return that value. > =20 > @@ -1040,7 +1045,7 @@ static int xfs_discard(BDRVRawState *s, int64_t o= ffset, uint64_t bytes) > fl.l_len =3D bytes; > =20 > if (xfsctl(NULL, s->fd, XFS_IOC_UNRESVSP64, &fl) < 0) { > - DEBUG_BLOCK_PRINT("cannot punch hole (%s)\n", strerror(errno))= ; > + DPRINTF("cannot punch hole (%s)\n", strerror(errno)); > return -errno; Here too. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --w4RenxxiGGtLHPFc0dA3PhnsQ36CsmWF1 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/ iQEcBAEBCAAGBQJVVKufAAoJEKeha0olJ0NqMjYH/Ru9XTWcROgsD0U6vxKxTl9O 8RD3DAg0/UHwz6rzZh5kAXZmNyC5/xdDhA+zH36piOgnMG4Nx4dIHRKGOXUKJ6Rk FqHmaSWQ9ERmJHvXU1uR9372toDkdPF4O0wePuzJlv2ElMEZlzN/TACpTeIgUQd2 wOmud4kst+/eftnzwZ/lA+9LDuHrOB5EP2a1xfnVQ0/bxHhp8qPZlw6zEISYZei8 RcN9yecWA5qJ9FfbSyMjqbHjBVjSOxXGYfQL+zc6sz4nJkQDRlCJSs2HeEfSIZOx 8lE+OrQwTVYBeY5eEEWrfA/EpciM8kd4u5M/irfMTyy9G6qyojJZPLeHIWlghKY= =XmbW -----END PGP SIGNATURE----- --w4RenxxiGGtLHPFc0dA3PhnsQ36CsmWF1--