[PATCH 2/4] virQEMUDriverConfigLoadNVRAMEntry: use VIR_AUTOFREE

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

 



Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros
to get rid of the cleanup section.

Requested-by: John Ferlan <jferlan@xxxxxxxxxx>
Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/qemu/qemu_conf.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index fc7101904e..04061b0135 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -829,31 +829,27 @@ static int
 virQEMUDriverConfigLoadNVRAMEntry(virQEMUDriverConfigPtr cfg,
                                   virConfPtr conf)
 {
-    char **nvram = NULL;
-    int ret = -1;
+    VIR_AUTOPTR(virString) nvram = NULL;
     size_t i;
 
     if (virConfGetValueStringList(conf, "nvram", false, &nvram) < 0)
-        goto cleanup;
+        return -1;
     if (nvram) {
         virFirmwareFreeList(cfg->firmwares, cfg->nfirmwares);
 
         cfg->nfirmwares = virStringListLength((const char *const *)nvram);
         if (nvram[0] && VIR_ALLOC_N(cfg->firmwares, cfg->nfirmwares) < 0)
-            goto cleanup;
+            return -1;
 
         for (i = 0; nvram[i] != NULL; i++) {
             if (VIR_ALLOC(cfg->firmwares[i]) < 0)
-                goto cleanup;
+                return -1;
             if (virFirmwareParse(nvram[i], cfg->firmwares[i]) < 0)
-                goto cleanup;
+                return -1;
         }
     }
 
-    ret = 0;
- cleanup:
-    virStringListFree(nvram);
-    return ret;
+    return 0;
 }
 
 
-- 
2.16.4

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