[libvirt] [PATCH v2 1/3] virsh: Make vshCommandOptScaledInt() use vshCommandOpt().

Michal Privoznik mprivozn at redhat.com
Wed May 27 14:47:12 UTC 2015


On 22.05.2015 10:59, Andrea Bolognani wrote:
> This aligns it to the other vshCommandOpt*() functions.
> ---
>  tools/virsh.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 4425774..11c2c30 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -1804,16 +1804,17 @@ vshCommandOptScaledInt(const vshCmd *cmd, const char *name,
>                         unsigned long long *value, int scale,
>                         unsigned long long max)
>  {
> -    const char *str;
> -    int ret;
> +    vshCmdOpt *arg;
>      char *end;
> +    int ret;
>  
> -    ret = vshCommandOptString(cmd, name, &str);
> -    if (ret <= 0)
> +    if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)

This cancels check of arg->def->flags & VSH_OFLAG_EMPTY_OK; but since
this flag makes sense only for string arguments, it's okay.

>          return ret;
> -    if (virStrToLong_ull(str, &end, 10, value) < 0 ||
> +
> +    if (virStrToLong_ull(arg->data, &end, 10, value) < 0 ||
>          virScaleInteger(value, end, scale, max) < 0)
>          return -1;
> +
>      return 1;
>  }
>  
> 

ACK

Michal




More information about the libvir-list mailing list