[libvirt] [PATCH 2/5] virsh: demonstrate use of VIR_AUTOPTR(virshDomain) on 'send-process-signal'

Daniel Henrique Barboza danielhb413 at gmail.com
Tue Sep 17 14:10:00 UTC 2019



On 9/16/19 9:45 AM, Peter Krempa wrote:
> Refactor the command code to use the new type.
>
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---

Reviewed-by: Daniel Henrique Barboza <danielhb413 at gmail.com>

>   tools/virsh-domain.c | 17 ++++++-----------
>   1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 3d26e81b22..9015c43ba2 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -8834,8 +8834,7 @@ static int getSignalNumber(vshControl *ctl, const char *signame)
>   static bool
>   cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
>   {
> -    virDomainPtr dom;
> -    bool ret = false;
> +    VIR_AUTOPTR(virshDomain) dom = NULL;
>       const char *signame;
>       long long pid_value;
>       int signum;
> @@ -8844,24 +8843,20 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
>           return false;
>
>       if (vshCommandOptLongLong(ctl, cmd, "pid", &pid_value) < 0)
> -        goto cleanup;
> +        return false;
>
>       if (vshCommandOptStringReq(ctl, cmd, "signame", &signame) < 0)
> -        goto cleanup;
> +        return false;
>
>       if ((signum = getSignalNumber(ctl, signame)) < 0) {
>           vshError(ctl, _("malformed signal name: %s"), signame);
> -        goto cleanup;
> +        return false;
>       }
>
>       if (virDomainSendProcessSignal(dom, pid_value, signum, 0) < 0)
> -        goto cleanup;
> -
> -    ret = true;
> +        return false;
>
> - cleanup:
> -    virshDomainFree(dom);
> -    return ret;
> +    return true;
>   }
>
>   /*




More information about the libvir-list mailing list