From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLZVM-0001yE-G5 for qemu-devel@nongnu.org; Wed, 11 Feb 2015 10:47:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLZVG-0005VE-Mo for qemu-devel@nongnu.org; Wed, 11 Feb 2015 10:47:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58802) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLZVG-0005V8-FD for qemu-devel@nongnu.org; Wed, 11 Feb 2015 10:47:02 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1BFl0WJ001558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 11 Feb 2015 10:47:01 -0500 Message-ID: <54DB7974.2050807@redhat.com> Date: Wed, 11 Feb 2015 08:47:00 -0700 From: Eric Blake MIME-Version: 1.0 References: <1423600146-7642-1-git-send-email-mreitz@redhat.com> <1423600146-7642-5-git-send-email-mreitz@redhat.com> In-Reply-To: <1423600146-7642-5-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Jvi4LnPHrdWk7qx1EMIt9fJ5wxENmNb7W" Subject: Re: [Qemu-devel] [PATCH v6 04/24] 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) --Jvi4LnPHrdWk7qx1EMIt9fJ5wxENmNb7W Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/10/2015 01:28 PM, 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 | 86 +++++++++++++++++++++++++++---------------= -------- > block/qcow2.h | 3 +- > 3 files changed, 53 insertions(+), 44 deletions(-) >=20 > @@ -744,10 +749,9 @@ int qcow2_alloc_clusters_at(BlockDriverState *bs, = uint64_t offset, > /* Check how many clusters there are free */ > cluster_index =3D offset >> s->cluster_bits; > for(i =3D 0; i < nb_clusters; i++) { > - refcount =3D qcow2_get_refcount(bs, cluster_index++); Worth fixing the spacing after 'for' while touching here? (might even already happen later in the series). But not important enough for a respin, and I won't even care if a maintainer doesn't fold it in. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Jvi4LnPHrdWk7qx1EMIt9fJ5wxENmNb7W 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/ iQEcBAEBCAAGBQJU23l0AAoJEKeha0olJ0NqqIIH/32KZ7YYyRuydqozsTNqz5wj Y0pyXhDnar1W/aurN7o9FMDfwA/ERL1u4vuPfdZrOk0puQiaGgLdF6QTmZ/SdSm5 e+V38SpVakIrjk6F3DvmnabnE2ajB2Pw1cDR14ooj4VVQaZWrnz0DAiiOVm30n0g oe8NBpXIzGmXfYGzMyLJbOXUGF1GKUIv/9WdlwBkGJtGeasTdXLDRM+hNISn5lsv g65giTyCQG6pZ7yClr1tV9VT3PersDDU83qdXfDQuWRnIg2rHgGwbpOpxHg1X1qR PQggSCbCsTYoAQDzmb3ZFVwi7BaRV6QpqxjA6+x176+0hc+ZNhI2ygIB5zLEy9w= =Z3FA -----END PGP SIGNATURE----- --Jvi4LnPHrdWk7qx1EMIt9fJ5wxENmNb7W--