]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Resolve Coverity DEADCODE
authorJohn Ferlan <jferlan@redhat.com>
Thu, 4 Sep 2014 19:42:08 +0000 (15:42 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 11 Sep 2014 12:10:13 +0000 (08:10 -0400)
Coverity points out that if 'dom' isn't returned from virDomainQemuAttach,
then the code already jumps to cleanup, so there was no need for the
subsequent if (dom != NULL) check.

I moved the error message about failure into the goto cleanup on failure
and then removed the if (dom != NULL)

Signed-off-by: John Ferlan <jferlan@redhat.com>
tools/virsh-domain.c

index 3169b45b05ddbc32d3e3c71197cff0bffd54f32d..cc1e5546fd543c69a12ae2c72c44f5504836be1c 100644 (file)
@@ -8498,18 +8498,16 @@ cmdQemuAttach(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (!(dom = virDomainQemuAttach(ctl->conn, pid_value, flags)))
-        goto cleanup;
-
-    if (dom != NULL) {
-        vshPrint(ctl, _("Domain %s attached to pid %u\n"),
-                 virDomainGetName(dom), pid_value);
-        virDomainFree(dom);
-        ret = true;
-    } else {
+    if (!(dom = virDomainQemuAttach(ctl->conn, pid_value, flags))) {
         vshError(ctl, _("Failed to attach to pid %u"), pid_value);
+        goto cleanup;
     }
 
+    vshPrint(ctl, _("Domain %s attached to pid %u\n"),
+                virDomainGetName(dom), pid_value);
+    virDomainFree(dom);
+    ret = true;
+
  cleanup:
     return ret;
 }