On 03/28/2013 10:47 AM, Pavel Hrdina wrote:
> If we provide error message we don't have to also provide return
> value because we could check if there is any error message or not.
> 
> Signed-off-by: Pavel Hrdina <phrd...@redhat.com>
> ---
>  block.c                   | 24 ++++++++++--------------
>  block/qcow2-snapshot.c    | 12 +++++-------
>  block/qcow2.h             |  6 +++---
>  block/rbd.c               | 15 ++++++---------
>  block/sheepdog.c          |  9 ++++-----
>  include/block/block.h     |  6 +++---
>  include/block/block_int.h |  6 +++---
>  qemu-img.c                |  9 ++++-----
>  savevm.c                  |  4 ++--
>  9 files changed, 40 insertions(+), 51 deletions(-)
> 

> @@ -2018,11 +2019,9 @@ static int img_snapshot(int argc, char **argv)
>          sn.date_sec = tv.tv_sec;
>          sn.date_nsec = tv.tv_usec * 1000;
>  
> -        ret = bdrv_snapshot_create(bs, &sn, NULL);
> -        if (ret) {
> -            error_report("Could not create snapshot '%s': %d (%s)",
> -                snapshot_name, ret, strerror(-ret));
> -        }
> +        local_err = NULL;
> +        bdrv_snapshot_create(bs, &sn, &local_err);
> +        ret = qemu_img_handle_error(local_err);

This sets ret==1 on error, but bdrv_snapshot_create used to return <0 on
error.  Then again, the tail of img_snapshot() normalizes all errors to
a 'return 1'.  Took me a few minutes to see, but no problem after all.

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

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