[libvirt] [PATCH 11/19] qemuBuildControllersByTypeCommandLine: use VIR_AUTOFREE

Ján Tomko jtomko at redhat.com
Tue Aug 20 12:59:10 UTC 2019


Reduce the scope of the variable to get it freed for every controller
processed.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/qemu/qemu_command.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index db8584243c..298a1c3fea 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3198,12 +3198,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;
@@ -3236,7 +3236,6 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
             continue;
         }
 
-        VIR_FREE(devstr);
         if (qemuBuildControllerDevStr(def, cont, qemuCaps, &devstr) < 0)
             goto cleanup;
 
@@ -3251,7 +3250,6 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
 
     ret = 0;
  cleanup:
-    VIR_FREE(devstr);
     return ret;
 }
 
-- 
2.19.2




More information about the libvir-list mailing list