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 <kw...@redhat.com>
> Signed-off-by: Max Reitz <mre...@redhat.com>
> ---
>  block/raw-posix.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)

Reviewed-by: Eric Blake <ebl...@redhat.com>

> -    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