From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4BC1-0001de-OS for qemu-devel@nongnu.org; Mon, 07 Jul 2014 11:51:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4BBw-00037M-0A for qemu-devel@nongnu.org; Mon, 07 Jul 2014 11:51:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4BBv-000378-MZ for qemu-devel@nongnu.org; Mon, 07 Jul 2014 11:50:55 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s67FotmF018600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 7 Jul 2014 11:50:55 -0400 Message-ID: <53BAC1DE.50708@redhat.com> Date: Mon, 07 Jul 2014 09:50:54 -0600 From: Eric Blake MIME-Version: 1.0 References: <1404747446-10215-1-git-send-email-kwolf@redhat.com> In-Reply-To: <1404747446-10215-1-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ahIgtP6ohUHgWm71VqdJeM1ixtvbTOFhe" Subject: Re: [Qemu-devel] [PATCH for-2.1] block: Fix bdrv_is_allocated() return value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-devel@nongnu.org Cc: stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ahIgtP6ohUHgWm71VqdJeM1ixtvbTOFhe Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/07/2014 09:37 AM, Kevin Wolf wrote: > bdrv_is_allocated() should return either 0 or 1 in successful cases. > We're lucky that currently, the callers that rely on this (e.g. because= > they check for ret =3D=3D 1) don't seem to break badly. They just might= skip > some optimisation or in the case of qemu-io 'map' print separate lines > where a single line would suffice. In theory, a wrong allocation status= > could lead to image corruption with certain operations, so let's fix > this quickly. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/block.c b/block.c > index f80e2b2..e2e9cbb 100644 > --- a/block.c > +++ b/block.c > @@ -4039,7 +4039,7 @@ int coroutine_fn bdrv_is_allocated(BlockDriverSta= te *bs, int64_t sector_num, > if (ret < 0) { > return ret; > } > - return (ret & BDRV_BLOCK_ALLOCATED); > + return !!(ret & BDRV_BLOCK_ALLOCATED); Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ahIgtP6ohUHgWm71VqdJeM1ixtvbTOFhe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTusHeAAoJEKeha0olJ0Nq/YIH/16aGe1ELxpdS0v4QmLz45ZF G9EOqm3SaLX5k8wyayx8wP8iE4nGE9d1lpGrlAq27OSugQcEe8na92b3omPDyqjI en9RUFjAcSjoGt0Fjp+Grab85TbVbVGNySNr8zpwUOteO3wiQrekYNlt9HTrEq44 3ZqhawX/1ZfR2Bel9twut9thp8643T4/NOuzzsSZZLJC7jn6mm4L4z9Qc3ol53wR JqnuAAHLK1YXV0oYh15IYGK1/PPzjfsKlw2eWzsv7SfoGvDtYgL0OgBoyXdClOWl GgAeQOZvaDotlw5N1t5lYz2u4XP+tE84hqt6WF2EHudS7KXkXjDV5zsuH5Kih9s= =WL6S -----END PGP SIGNATURE----- --ahIgtP6ohUHgWm71VqdJeM1ixtvbTOFhe--