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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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

Reviewed-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>

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

  /*

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux