From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qcgqp-0003Jj-Ni for qemu-devel@nongnu.org; Fri, 01 Jul 2011 12:45:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qcgqm-0000yW-1U for qemu-devel@nongnu.org; Fri, 01 Jul 2011 12:45:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27726) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qcgql-0000y8-Gg for qemu-devel@nongnu.org; Fri, 01 Jul 2011 12:45:51 -0400 Message-ID: <4E0DF88B.2040409@redhat.com> Date: Fri, 01 Jul 2011 18:40:43 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1309496142-14228-1-git-send-email-famcool@gmail.com> <1309496142-14228-9-git-send-email-famcool@gmail.com> In-Reply-To: <1309496142-14228-9-git-send-email-famcool@gmail.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v6 08/12] VMDK: change get_cluster_offset return type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: stefanha@gmail.com, qemu-devel@nongnu.org, hch@lst.de Am 01.07.2011 06:55, schrieb Fam Zheng: > The return type of get_cluster_offset was an offset that use 0 to denote > 'not allocated', this will be no longer true for flat extents, as we see > flat extent file as a single huge cluster whose offset is 0 and length > is the whole file length. > So now we use int return value, 0 means success and otherwise offset > invalid. > > Signed-off-by: Fam Zheng > --- > block/vmdk.c | 73 +++++++++++++++++++++++++++++++--------------------------- > 1 files changed, 39 insertions(+), 34 deletions(-) > > diff --git a/block/vmdk.c b/block/vmdk.c > index 8783629..40e4464 100644 > --- a/block/vmdk.c > +++ b/block/vmdk.c > @@ -685,18 +685,23 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data) > return 0; > } > > -static uint64_t get_cluster_offset(BlockDriverState *bs, > +static int get_cluster_offset(BlockDriverState *bs, > VmdkExtent *extent, > VmdkMetaData *m_data, > - uint64_t offset, int allocate) > + uint64_t offset, > + int allocate, > + uint64_t *cluster_offset) > { > unsigned int l1_index, l2_offset, l2_index; > int min_index, i, j; > uint32_t min_count, *l2_table, tmp = 0; > - uint64_t cluster_offset; > > if (m_data) > m_data->valid = 0; > + if (extent->flat) { > + *cluster_offset = 0; > + return 0; > + } > > l1_index = (offset >> 9) / extent->l1_entry_sectors; > if (l1_index >= extent->l1_size) { Let me complete what comes next: l1_index = (offset >> 9) / extent->l1_entry_sectors; if (l1_index >= extent->l1_size) { return 0; } l2_offset = extent->l1_table[l1_index]; if (!l2_offset) { return 0; } Shouldn't these returns be changed to -1? Also there is a return 0; after a failed read, which doesn't seem to be changed. Kevin