From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKtFs-0000Kv-SQ for qemu-devel@nongnu.org; Fri, 22 Aug 2014 14:08:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKtFn-00084d-4B for qemu-devel@nongnu.org; Fri, 22 Aug 2014 14:08:04 -0400 Received: from dew.nodalink.com ([95.130.14.197]:39928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKtFm-00084Y-Tw for qemu-devel@nongnu.org; Fri, 22 Aug 2014 14:07:59 -0400 Date: Fri, 22 Aug 2014 18:07:58 +0000 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140822180758.GE9526@nodalink.com> References: <1408725104-17176-1-git-send-email-mreitz@redhat.com> <1408725104-17176-5-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1408725104-17176-5-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 04/10] qcow2: Reuse refcount table in calculate_refcounts() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi , =?iso-8859-1?Q?Beno=EEt?= Canet On Fri, Aug 22, 2014 at 06:31:38PM +0200, Max Reitz wrote: > We will later call calculate_refcounts multiple times, so reuse the > refcount table if possible. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-refcount.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) >=20 > diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c > index 2b728ef..babe6cb 100644 > --- a/block/qcow2-refcount.c > +++ b/block/qcow2-refcount.c > @@ -1584,10 +1584,12 @@ static int calculate_refcounts(BlockDriverState= *bs, BdrvCheckResult *res, > QCowSnapshot *sn; > int ret; > =20 > - *refcount_table =3D g_try_new0(uint16_t, *nb_clusters); > - if (*nb_clusters && *refcount_table =3D=3D NULL) { > - res->check_errors++; > - return -ENOMEM; > + if (!*refcount_table) { > + *refcount_table =3D g_try_new0(uint16_t, *nb_clusters); > + if (*nb_clusters && *refcount_table =3D=3D NULL) { > + res->check_errors++; > + return -ENOMEM; > + } > } > =20 > /* header */ > @@ -1694,7 +1696,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, B= drvCheckResult *res, > { > BDRVQcowState *s =3D bs->opaque; > int64_t size, highest_cluster, nb_clusters; > - uint16_t *refcount_table; > + uint16_t *refcount_table =3D NULL; > int ret; > =20 > size =3D bdrv_getlength(bs->file); > --=20 > 2.0.4 >=20 Reviewed-by: Beno=EEt Canet