From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF13Z-0001Jd-Jp for qemu-devel@nongnu.org; Mon, 20 Jun 2016 11:24:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF13X-00071x-HP for qemu-devel@nongnu.org; Mon, 20 Jun 2016 11:24:09 -0400 References: <20160620142623.24471-1-mreitz@redhat.com> <20160620142623.24471-2-mreitz@redhat.com> From: Eric Blake Message-ID: <57680A8E.4090009@redhat.com> Date: Mon, 20 Jun 2016 09:23:58 -0600 MIME-Version: 1.0 In-Reply-To: <20160620142623.24471-2-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="iXxsqG7oQQWSVtjs02t4CEjxqbm9uqaaG" Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-io: Use correct range limitations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-block@nongnu.org Cc: Kevin Wolf , John Snow , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --iXxsqG7oQQWSVtjs02t4CEjxqbm9uqaaG From: Eric Blake To: Max Reitz , qemu-block@nongnu.org Cc: Kevin Wolf , John Snow , qemu-devel@nongnu.org Message-ID: <57680A8E.4090009@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-io: Use correct range limitations References: <20160620142623.24471-1-mreitz@redhat.com> <20160620142623.24471-2-mreitz@redhat.com> In-Reply-To: <20160620142623.24471-2-mreitz@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/20/2016 08:26 AM, Max Reitz wrote: > create_iovec() has a comment lamenting the lack of SIZE_T_MAX. Since > there actually is a SIZE_MAX, use it. >=20 > Two places use INT_MAX for checking the upper bound of a sector count > that is used as an argument for a blk_*() function (blk_discard() and > blk_write_compressed(), respectively). BDRV_REQUEST_MAX_SECTORS should > be used instead. >=20 > And finally, do_co_pwrite_zeroes() used to similarly check that the > sector count does not exceed INT_MAX. However, this function is now > backed by blk_co_pwrite_zeroes() which takes bytes as an argument > instead of sectors. Therefore, it should be the byte count that does no= t > exceed INT_MAX, not the sector count. >=20 > Signed-off-by: Max Reitz > --- > qemu-io-cmds.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) >=20 > @@ -500,7 +499,7 @@ static int do_write_compressed(BlockBackend *blk, c= har *buf, int64_t offset, > { > int ret; > =20 > - if (count >> 9 > INT_MAX) { > + if (count >> 9 > BDRV_REQUEST_MAX_SECTORS) { Worth s/9/BDRV_SECTOR_BITS/ while touching it? But not a show-stopper either way. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --iXxsqG7oQQWSVtjs02t4CEjxqbm9uqaaG 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/ iQEcBAEBCAAGBQJXaAqOAAoJEKeha0olJ0NqqEUH/3g0Ac0lWyYFYCbdop68KDq9 mTTeQMDLsqq4J5eE5ClbLT+ZbpeLNlcIhQNVU9HjaXftV//dTPTYO17jDX3ApKBy nz+qAxmwDJgdKN4yjzt/6cx4mOPI/zZgge/El7OtwVK5hFMghzx3XDPVUbBbk53d v7v7uNbgBYHKCarRfyox5Ln61U4QcOjF6phxp3HSUE5kujaA1BQGGDsuHTB7Lac5 hj1TS2dMHL8nDCi023emKKddm089XPjJ8nOsPNbNhApF8eLnWudr+smtZpNVhMGg WD6a/GRKk1jz7KYVvBBfFJrMD6khsmpfVHbDHq+zeaIptyJt/I2hiHuMTnMLnOE= =ogg4 -----END PGP SIGNATURE----- --iXxsqG7oQQWSVtjs02t4CEjxqbm9uqaaG--