diff mbox

[v4,01/10] vmdk: remove ret from inner scope.

Message ID 1375775095-19456-2-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng Aug. 6, 2013, 7:44 a.m. UTC
A inner scope "ret" variable hides the real return code, it will always
return VMDK_OK for bs->backing_hd. Fix this by removing the declaration.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/vmdk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Kevin Wolf Aug. 6, 2013, 12:15 p.m. UTC | #1
Am 06.08.2013 um 09:44 hat Fam Zheng geschrieben:
> A inner scope "ret" variable hides the real return code, it will always
> return VMDK_OK for bs->backing_hd. Fix this by removing the declaration.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>

In the original code there is no problem.

> ---
>  block/vmdk.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 3756333..f42657b 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -813,8 +813,8 @@ static int get_whole_cluster(BlockDriverState *bs,
>      /* we will be here if it's first write on non-exist grain(cluster).
>       * try to read from parent image, if exist */
>      if (bs->backing_hd) {
> -        int ret;
> -
> +        whole_grain =
> +            qemu_blockalign(bs, extent->cluster_sectors << BDRV_SECTOR_BITS);
>          if (!vmdk_is_cid_valid(bs)) {
>              return VMDK_ERROR;
>          }

After this patch, there are two:

block/vmdk.c: In function 'get_whole_cluster':
block/vmdk.c:816:21: error: incompatible types when assigning to type
'uint8_t[(sizetype)(extent->cluster_sectors * 512u)]' from type 'void *'
block/vmdk.c:824:9: error: 'ret' undeclared (first use in this function)

Kevin
Jeff Cody Aug. 6, 2013, 12:37 p.m. UTC | #2
On Tue, Aug 06, 2013 at 02:15:13PM +0200, Kevin Wolf wrote:
> Am 06.08.2013 um 09:44 hat Fam Zheng geschrieben:
> > A inner scope "ret" variable hides the real return code, it will always
> > return VMDK_OK for bs->backing_hd. Fix this by removing the declaration.
> > 
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> 
> In the original code there is no problem.
>

Right, this whole patch should be squashed into patch 9.  Looks like a
bad rebase of the patches.

> > ---
> >  block/vmdk.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/block/vmdk.c b/block/vmdk.c
> > index 3756333..f42657b 100644
> > --- a/block/vmdk.c
> > +++ b/block/vmdk.c
> > @@ -813,8 +813,8 @@ static int get_whole_cluster(BlockDriverState *bs,
> >      /* we will be here if it's first write on non-exist grain(cluster).
> >       * try to read from parent image, if exist */
> >      if (bs->backing_hd) {
> > -        int ret;
> > -


> > +        whole_grain =
> > +            qemu_blockalign(bs, extent->cluster_sectors << BDRV_SECTOR_BITS);
             ^^^^^^^^^^^^^^^^^^
This hunk is from patch 9.

> >          if (!vmdk_is_cid_valid(bs)) {
> >              return VMDK_ERROR;
> >          }
> 
> After this patch, there are two:
> 
> block/vmdk.c: In function 'get_whole_cluster':
> block/vmdk.c:816:21: error: incompatible types when assigning to type
> 'uint8_t[(sizetype)(extent->cluster_sectors * 512u)]' from type 'void *'
> block/vmdk.c:824:9: error: 'ret' undeclared (first use in this function)
> 
> Kevin
diff mbox

Patch

diff --git a/block/vmdk.c b/block/vmdk.c
index 3756333..f42657b 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -813,8 +813,8 @@  static int get_whole_cluster(BlockDriverState *bs,
     /* we will be here if it's first write on non-exist grain(cluster).
      * try to read from parent image, if exist */
     if (bs->backing_hd) {
-        int ret;
-
+        whole_grain =
+            qemu_blockalign(bs, extent->cluster_sectors << BDRV_SECTOR_BITS);
         if (!vmdk_is_cid_valid(bs)) {
             return VMDK_ERROR;
         }