]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Resolve Coverity UNINIT
authorJohn Ferlan <jferlan@redhat.com>
Sat, 15 Aug 2015 13:15:42 +0000 (09:15 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Sat, 15 Aug 2015 19:53:26 +0000 (15:53 -0400)
Coverity complained that 'vm' wasn't initialized before jumping to
cleanup: and calling virDomainObjEndAPI if the VIR_STRDUP fails.
So I initialized vm = NULL and also moved the VIR_STRDUP closer to
usage and used endjob for goto. Lots of other reasons for failures.

src/qemu/qemu_driver.c

index 3683591c8f91e485494c1182d4172097cb4089c3..4c0532432ac3a6556bba9e3545df23b4a467db03 100644 (file)
@@ -19888,7 +19888,7 @@ static int qemuDomainRename(virDomainPtr dom,
 {
     virQEMUDriverPtr driver = dom->conn->privateData;
     virQEMUDriverConfigPtr cfg = NULL;
-    virDomainObjPtr vm;
+    virDomainObjPtr vm = NULL;
     virObjectEventPtr event_new = NULL;
     virObjectEventPtr event_old = NULL;
     int ret = -1;
@@ -19902,9 +19902,6 @@ static int qemuDomainRename(virDomainPtr dom,
 
     virCheckFlags(0, ret);
 
-    if (VIR_STRDUP(new_dom_name, new_name) < 0)
-        goto cleanup;
-
     if (!(vm = qemuDomObjFromDomain(dom)))
         goto cleanup;
 
@@ -19940,6 +19937,9 @@ static int qemuDomainRename(virDomainPtr dom,
         goto endjob;
     }
 
+    if (VIR_STRDUP(new_dom_name, new_name) < 0)
+        goto endjob;
+
     if (virAsprintf(&rename_log_msg, ": domain %s has been renamed to %s\n",
                     vm->def->name, new_name) < 0) {
         goto endjob;