From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrqWE-0004qb-OZ for qemu-devel@nongnu.org; Tue, 03 Jun 2014 11:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrqW8-0002Kt-Oj for qemu-devel@nongnu.org; Tue, 03 Jun 2014 11:20:54 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:38733 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrqW8-0002Kc-HP for qemu-devel@nongnu.org; Tue, 03 Jun 2014 11:20:48 -0400 Date: Tue, 3 Jun 2014 17:20:46 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140603152046.GE21314@irqsave.net> References: <1401801062-9154-1-git-send-email-kwolf@redhat.com> <1401801062-9154-22-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1401801062-9154-22-git-send-email-kwolf@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 21/21] qcow2: Return useful error code in refcount_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: benoit.canet@irqsave.net, mreitz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, armbru@redhat.com The Tuesday 03 Jun 2014 =E0 15:11:02 (+0200), Kevin Wolf wrote : > From: Max Reitz >=20 > If bdrv_pread() returns an error, it is very unlikely that it was > ENOMEM. In this case, the return value should be passed along; as > bdrv_pread() will always either return the number of bytes read or a > negative value (the error code), the condition for checking whether > bdrv_pread() failed can be simplified (and clarified) as well. >=20 > Signed-off-by: Max Reitz > Signed-off-by: Kevin Wolf > --- > block/qcow2-refcount.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c > index a234c7a..6b367c8 100644 > --- a/block/qcow2-refcount.c > +++ b/block/qcow2-refcount.c > @@ -49,19 +49,21 @@ int qcow2_refcount_init(BlockDriverState *bs) > =20 > if (s->refcount_table_size > 0) { > if (s->refcount_table =3D=3D NULL) { > + ret =3D -ENOMEM; > goto fail; > } > BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD); > ret =3D bdrv_pread(bs->file, s->refcount_table_offset, > s->refcount_table, refcount_table_size2); > - if (ret !=3D refcount_table_size2) > + if (ret < 0) { > goto fail; > + } > for(i =3D 0; i < s->refcount_table_size; i++) > be64_to_cpus(&s->refcount_table[i]); > } > return 0; > fail: > - return -ENOMEM; > + return ret; > } > =20 > void qcow2_refcount_close(BlockDriverState *bs) > --=20 > 1.8.3.1 >=20 >=20 Reviewed-by: Benoit Canet