From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwC03-0004dI-Uw for qemu-devel@nongnu.org; Wed, 03 Dec 2014 10:38:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwBzy-0003Xv-Vh for qemu-devel@nongnu.org; Wed, 03 Dec 2014 10:37:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwBzy-0003WW-OW for qemu-devel@nongnu.org; Wed, 03 Dec 2014 10:37:50 -0500 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 sB3Fbmqr014670 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 3 Dec 2014 10:37:49 -0500 Message-ID: <547F2E4B.2000905@redhat.com> Date: Wed, 03 Dec 2014 08:37:47 -0700 From: Eric Blake MIME-Version: 1.0 References: <1417613866-25890-1-git-send-email-mreitz@redhat.com> <1417613866-25890-5-git-send-email-mreitz@redhat.com> In-Reply-To: <1417613866-25890-5-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="JdtL80nTLRlaE3M4WuH0XaJgIt7SRVxpD" Subject: Re: [Qemu-devel] [PATCH v4 04/26] qcow2: Only return status from qcow2_get_refcount List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --JdtL80nTLRlaE3M4WuH0XaJgIt7SRVxpD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/03/2014 06:37 AM, Max Reitz wrote: > Refcounts can theoretically be of type uint64_t; in order to be able to= > represent the full range, qcow2_get_refcount() cannot use a single > variable to represent both all refcount values and also keep some value= s > reserved for errors. >=20 > One solution would be to add an Error pointer parameter to > qcow2_get_refcount(); however, no caller could (currently) pass that > error message, so it would have to be emitted immediately and be > passed to the next caller by returning -EIO or something similar. > Therefore, an Error parameter does not offer any advantages here. >=20 > The solution applied by this patch is simpler to use. Because no caller= > would be able to pass the error message, they would have to print it an= d > free it, whereas with this patch the caller only needs to pass the > returned integer (which is often a no-op from the code perspective, > because that integer will be stored in a variable "ret" which will be > returned by the fail path of many callers). >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-cluster.c | 8 ++--- > block/qcow2-refcount.c | 79 +++++++++++++++++++++++++++---------------= -------- > block/qcow2.h | 3 +- > 3 files changed, 49 insertions(+), 41 deletions(-) >=20 > @@ -1670,7 +1677,7 @@ static void compare_refcounts(BlockDriverState *b= s, BdrvCheckResult *res, > =20 > if (num_fixed) { > ret =3D update_refcount(bs, i << s->cluster_bits, 1, > - refcount2 - refcount1, > + (int)refcount2 - (int)refcount1,= The casts look a bit odd (uint16_t already naturally promotes to int for 32-bit int), but keep it, since we'll have to re-think this operation when a later patch widens to 64 bits anyways. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --JdtL80nTLRlaE3M4WuH0XaJgIt7SRVxpD 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 iQEcBAEBCAAGBQJUfy5LAAoJEKeha0olJ0NqwZoIAJ9ttFlZ+iZZquu2E3yLlXLv WbP3wFg3OGERMoA3vhrnJCNKdhNitZEjlBJPy87dRYKQsVnVVefwlRlTvKbgc4GV 8aCwbu5j1S/6LNODfDKyWr48tjCmGGmPvhp919NqT+2fgFqGojRzam6276h+J2qQ +za/4GZ2iEMpibeckx7w0vZP9jUhDXbVh65nSbOxUdFbnQdoFBV6rnb0if03Oqmc aCcdgkLuNInwY8hOOLmHHA28XBzZRStFict38RFqPOB2u4vtk+z5EoNTkS3nXNpB Se+WZoJHGPqH4wrcyf7goOzgTSXyGzV2vNRJnryN6ouuD9rwCXb7jiVak8i2fC8= =wtfj -----END PGP SIGNATURE----- --JdtL80nTLRlaE3M4WuH0XaJgIt7SRVxpD--