]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuBuildControllersByTypeCommandLine: use VIR_AUTOFREE
authorJán Tomko <jtomko@redhat.com>
Tue, 20 Aug 2019 11:21:28 +0000 (13:21 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 26 Aug 2019 20:16:06 +0000 (22:16 +0200)
Reduce the scope of the variable to get it freed for every controller
processed.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c

index 3847d3e8af5f3a87f546e846ed94825e18d15d9a..05ac183914a4ab7aa3e921b91fd4fed7168fca5d 100644 (file)
@@ -3191,12 +3191,12 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
                                       virQEMUCapsPtr qemuCaps,
                                       virDomainControllerType type)
 {
-    char *devstr = NULL;
     int ret = -1;
     size_t i;
 
     for (i = 0; i < def->ncontrollers; i++) {
         virDomainControllerDefPtr cont = def->controllers[i];
+        VIR_AUTOFREE(char *) devstr = NULL;
 
         if (cont->type != type)
             continue;
@@ -3229,7 +3229,6 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
             continue;
         }
 
-        VIR_FREE(devstr);
         if (qemuBuildControllerDevStr(def, cont, qemuCaps, &devstr) < 0)
             goto cleanup;
 
@@ -3244,7 +3243,6 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
 
     ret = 0;
  cleanup:
-    VIR_FREE(devstr);
     return ret;
 }