From: Peter Krempa Date: Mon, 9 Sep 2019 08:39:04 +0000 (+0200) Subject: virsh: demonstrate use of VIR_AUTOPTR(virshDomain) on 'send-process-signal' X-Git-Tag: v5.8.0-rc1~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec1ea119888718796662453f6515d0a6f05e18ff;p=thirdparty%2Flibvirt.git virsh: demonstrate use of VIR_AUTOPTR(virshDomain) on 'send-process-signal' Refactor the command code to use the new type. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: Ján Tomko --- 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; } /*