[PATCH 027/103] virQEMUBuildCommandLineJSONIterate: Simplify logic

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

 



With automatic memory freeing we can simplify the function to avoid two
almost-identical calls to virQEMUBuildCommandLineJSONRecurse.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/virqemu.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index e31451dff4..3e9311e3c7 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -158,23 +158,17 @@ virQEMUBuildCommandLineJSONIterate(const char *key,
                                    void *opaque)
 {
     struct virQEMUCommandLineJSONIteratorData *data = opaque;
+    g_autofree char *tmpkey = NULL;

     if (STREQ_NULLABLE(key, data->skipKey))
         return 0;

-    if (data->prefix) {
-        g_autofree char *tmpkey = NULL;
+    if (data->prefix)
+        key = tmpkey = g_strdup_printf("%s.%s", data->prefix, key);

-        tmpkey = g_strdup_printf("%s.%s", data->prefix, key);
-
-        return virQEMUBuildCommandLineJSONRecurse(tmpkey, value, data->buf,
-                                                  data->skipKey,
-                                                  data->arrayFunc, false);
-    } else {
-        return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf,
-                                                  data->skipKey,
-                                                  data->arrayFunc, false);
-    }
+    return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf,
+                                              data->skipKey,
+                                              data->arrayFunc, false);
 }


-- 
2.31.1




[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