From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrTjZ-0001RX-EC for qemu-devel@nongnu.org; Mon, 02 Jun 2014 11:01:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrTjQ-0001RD-Tk for qemu-devel@nongnu.org; Mon, 02 Jun 2014 11:01:09 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:38631 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrTjQ-0001R8-I6 for qemu-devel@nongnu.org; Mon, 02 Jun 2014 11:01:00 -0400 Date: Mon, 2 Jun 2014 17:00:59 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140602150059.GE8181@irqsave.net> References: <1401473631-10724-1-git-send-email-armbru@redhat.com> <1401473631-10724-6-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1401473631-10724-6-git-send-email-armbru@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 05/10] block: Use bdrv_nb_sectors() in bdrv_co_get_block_status() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com The Friday 30 May 2014 =E0 20:13:46 (+0200), Markus Armbruster wrote : > Instead of bdrv_getlength(). >=20 > Replace variables length, length2 by total_sectors, nb_sectors2. > Bonus: use total_sectors instead of the slightly unclean > bs->total_sectors. >=20 > Signed-off-by: Markus Armbruster > Reviewed-by: Eric Blake > --- > block.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) >=20 > diff --git a/block.c b/block.c > index 6639d09..cfeb497 100644 > --- a/block.c > +++ b/block.c > @@ -3926,21 +3926,21 @@ static int64_t coroutine_fn bdrv_co_get_block_s= tatus(BlockDriverState *bs, > int64_t sector_nu= m, > int nb_sectors, i= nt *pnum) > { > - int64_t length; > + int64_t total_sectors; > int64_t n; > int64_t ret, ret2; > =20 > - length =3D bdrv_getlength(bs); > - if (length < 0) { > - return length; > + total_sectors =3D bdrv_nb_sectors(bs); > + if (total_sectors < 0) { > + return total_sectors; > } > =20 > - if (sector_num >=3D (length >> BDRV_SECTOR_BITS)) { > + if (sector_num >=3D total_sectors) { > *pnum =3D 0; > return 0; > } > =20 > - n =3D bs->total_sectors - sector_num; > + n =3D total_sectors - sector_num; > if (n < nb_sectors) { > nb_sectors =3D n; > } > @@ -3975,8 +3975,8 @@ static int64_t coroutine_fn bdrv_co_get_block_sta= tus(BlockDriverState *bs, > ret |=3D BDRV_BLOCK_ZERO; > } else if (bs->backing_hd) { > BlockDriverState *bs2 =3D bs->backing_hd; > - int64_t length2 =3D bdrv_getlength(bs2); > - if (length2 >=3D 0 && sector_num >=3D (length2 >> BDRV_SEC= TOR_BITS)) { > + int64_t nb_sectors2 =3D bdrv_nb_sectors(bs2); > + if (nb_sectors2 >=3D 0 && sector_num >=3D nb_sectors2) { > ret |=3D BDRV_BLOCK_ZERO; > } > } > --=20 > 1.9.3 >=20 >=20 Reviewed-by: Benoit Canet