[libvirt PATCH v6 04/15] xen_xl: Adapt xenParseCmdline due to changes in xenConfigGetString

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

 



xenConfigGetString returns a newly-allocated pointer and it has to be
freed by the caller.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 src/xenconfig/xen_xl.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 19b6604e05..e4ef061cdb 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -65,37 +65,44 @@ extern int xlu_disk_parse(XLU_Config *cfg,
 static int xenParseCmdline(virConfPtr conf, char **r_cmdline)
 {
     char *cmdline = NULL;
-    const char *root, *extra, *buf;
+    const char *root = NULL, *extra = NULL, *buf = NULL;
+    int ret = -1;
 
     if (xenConfigGetString(conf, "cmdline", &buf, NULL) < 0)
-        return -1;
+        goto cleanup;
 
     if (xenConfigGetString(conf, "root", &root, NULL) < 0)
-        return -1;
+        goto cleanup;
 
     if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
-        return -1;
+        goto cleanup;
 
     if (buf) {
         if (VIR_STRDUP(cmdline, buf) < 0)
-            return -1;
+            goto cleanup;
         if (root || extra)
             VIR_WARN("ignoring root= and extra= in favour of cmdline=");
     } else {
         if (root && extra) {
             if (virAsprintf(&cmdline, "root=%s %s", root, extra) < 0)
-                return -1;
+                goto cleanup;
         } else if (root) {
             if (virAsprintf(&cmdline, "root=%s", root) < 0)
-                return -1;
+                goto cleanup;
         } else if (extra) {
             if (VIR_STRDUP(cmdline, extra) < 0)
-                return -1;
+                goto cleanup;
         }
     }
 
     *r_cmdline = cmdline;
-    return 0;
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(buf);
+    VIR_FREE(extra);
+    VIR_FREE(root);
+    return ret;
 }
 
 static int
-- 
2.17.1

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