On 10/03/2017 09:00 PM, Eric Blake wrote: > Compare the following images with all-zero contents: > $ truncate --size 1M A > $ qemu-img create -f qcow2 -o preallocation=off B 1G > $ qemu-img create -f qcow2 -o preallocation=metadata C 1G >
> Signed-off-by: Eric Blake <ebl...@redhat.com> > Reviewed-by: John Snow <js...@redhat.com> > Reviewed-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> > > +++ b/qemu-img.c > @@ -1481,11 +1481,11 @@ static int img_compare(int argc, char **argv) > while (sector_num < progress_base) { > int64_t count; > > - ret = bdrv_is_allocated_above(blk_bs(blk_over), NULL, > + ret = bdrv_block_status_above(blk_bs(blk_over), NULL, Just now noticing: in this function, ret is 32-bit, but bdrv_block_status_above() returns 64-bit values... > sector_num * BDRV_SECTOR_SIZE, > (progress_base - sector_num) * > BDRV_SECTOR_SIZE, > - &count); > + &count, NULL); > if (ret < 0) { ...which could make for a false positive in a static checker (none of our implementations return a negative value beyond INT_MIN for wrapping to be a serious concern). So that's yet another reason why I am liking Kevin's proposal to split the returned offset to be a by-reference parameter rather than squashed into the return type, as it will let me use a 32-bit return type and avoid worrying about this corner case. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature