qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 21/21] qcow2: Return useful error code in ref


From: Benoît Canet
Subject: Re: [Qemu-devel] [PATCH v3 21/21] qcow2: Return useful error code in refcount_init()
Date: Tue, 3 Jun 2014 17:20:46 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

The Tuesday 03 Jun 2014 à 15:11:02 (+0200), Kevin Wolf wrote :
> From: Max Reitz <address@hidden>
> 
> 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.
> 
> Signed-off-by: Max Reitz <address@hidden>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
>  block/qcow2-refcount.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> 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)
>  
>      if (s->refcount_table_size > 0) {
>          if (s->refcount_table == NULL) {
> +            ret = -ENOMEM;
>              goto fail;
>          }
>          BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);
>          ret = bdrv_pread(bs->file, s->refcount_table_offset,
>                           s->refcount_table, refcount_table_size2);
> -        if (ret != refcount_table_size2)
> +        if (ret < 0) {
>              goto fail;
> +        }
>          for(i = 0; i < s->refcount_table_size; i++)
>              be64_to_cpus(&s->refcount_table[i]);
>      }
>      return 0;
>   fail:
> -    return -ENOMEM;
> +    return ret;
>  }
>  
>  void qcow2_refcount_close(BlockDriverState *bs)
> -- 
> 1.8.3.1
> 
> 
Reviewed-by: Benoit Canet <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]