qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 2/3] raw-posix: raw_co_get_block_status() ret


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v3 2/3] raw-posix: raw_co_get_block_status() return value
Date: Wed, 22 Oct 2014 11:00:43 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 10/22/2014 09:57 AM, Max Reitz wrote:
> Instead of generating the full return value thrice in try_fiemap(),
> try_seek_hole() and as a fall-back in raw_co_get_block_status() itself,
> generate the value only in raw_co_get_block_status().
> 
> While at it, also remove the pnum parameter from try_fiemap() and
> try_seek_hole().
> 
> Suggested-by: Kevin Wolf <address@hidden>
> Signed-off-by: Max Reitz <address@hidden>
> ---
>  block/raw-posix.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)

Reviewed-by: Eric Blake <address@hidden>

> -    ret = try_seek_hole(bs, start, &data, &hole, pnum);
> +    ret = try_seek_hole(bs, start, &data, &hole);
>      if (ret < 0) {
> -        ret = try_fiemap(bs, start, &data, &hole, nb_sectors, pnum);
> +        ret = try_fiemap(bs, start, &data, &hole, nb_sectors);
>          if (ret < 0) {
>              /* Assume everything is allocated. */
>              data = 0;
>              hole = start + nb_sectors * BDRV_SECTOR_SIZE;
> -            ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
> +            ret = 0;
>          }
>      }
>  
> +    assert(ret >= 0);

I'm not sure the assertion adds much (the lines above are fairly easy to
reason about ret always being set), but it does protect against later
code addition, so I'm not opposed to leaving it.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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