From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgclm-0002j7-IW for qemu-devel@nongnu.org; Tue, 21 Oct 2014 12:58:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xgclh-00007V-Fy for qemu-devel@nongnu.org; Tue, 21 Oct 2014 12:58:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgclh-000078-75 for qemu-devel@nongnu.org; Tue, 21 Oct 2014 12:58:45 -0400 Message-ID: <544690BE.1050802@redhat.com> Date: Tue, 21 Oct 2014 10:58:38 -0600 From: Eric Blake MIME-Version: 1.0 References: <1413881486-24710-1-git-send-email-mreitz@redhat.com> <1413881486-24710-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1413881486-24710-2-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LMk5l5IUcqxr1fwuFP4vx3eRsRqPKMtUR" Subject: Re: [Qemu-devel] [PATCH 1/2] block/vdi: Use {DIV_,}ROUND_UP List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Weil , =?UTF-8?B?QmVub8OudCBDYW5ldA==?= , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LMk5l5IUcqxr1fwuFP4vx3eRsRqPKMtUR Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/21/2014 02:51 AM, Max Reitz wrote: > There are macros for these operations, so make use of them. >=20 > Signed-off-by: Max Reitz > --- > block/vdi.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) >=20 > @@ -475,7 +474,7 @@ static int vdi_open(BlockDriverState *bs, QDict *op= tions, int flags, > s->header =3D header; > =20 > bmap_size =3D header.blocks_in_image * sizeof(uint32_t); > - bmap_size =3D (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE; > + bmap_size =3D DIV_ROUND_UP(bmap_size, SECTOR_SIZE); Is it worth consolidating these two assignments into one: bmap_size =3D DIV_ROUND_UP(header.blocks_in_image * sizeof(uint32_t), SECTOR_SIZE); > @@ -736,10 +735,10 @@ static int vdi_create(const char *filename, QemuO= pts *opts, Error **errp) > =20 > /* We need enough blocks to store the given disk size, > so always round up. */ > - blocks =3D (bytes + block_size - 1) / block_size; > + blocks =3D DIV_ROUND_UP(bytes, block_size); > =20 > bmap_size =3D blocks * sizeof(uint32_t); > - bmap_size =3D ((bmap_size + SECTOR_SIZE - 1) & ~(SECTOR_SIZE -1));= > + bmap_size =3D ROUND_UP(bmap_size, SECTOR_SIZE); and again? Either way, Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --LMk5l5IUcqxr1fwuFP4vx3eRsRqPKMtUR 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 iQEcBAEBCAAGBQJURpC+AAoJEKeha0olJ0NqvawIAKTfgX6s00M9RERzc7s5A0MC XIsFMAXuxqO82Eu+2gS/31sfT/SLchbfTA+Q8H94XP1sfUM2FsSNd90av+GJTKeE nhsv9Quj4D2RM8QkpOHKW6b/mo1suFKtdIx2v3gdWsu6Q9xo7eESYqjlGjufNYzm N4LWmomX4HsW6A3gYQgyaEj+1FWmxXCEmGZAv46adpcj8ta12ocVriN+y7APOhFs aVGRdFf/5g//zm/4EMGXX1Rq/CwziekLVTQGrgt5nI05nkZVPqUwn3uJHHfw2BEf 9vD2MRstX0SE6X665ytVibgdvF/NucsDK33tUhN8Qk102N/MTFIbGX8jvMb+SxY= =pzHD -----END PGP SIGNATURE----- --LMk5l5IUcqxr1fwuFP4vx3eRsRqPKMtUR--