thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
26ba25
From 26a9117f9c190c15102378ca14963c17f04c8e57 Mon Sep 17 00:00:00 2001
26ba25
From: Markus Armbruster <armbru@redhat.com>
26ba25
Date: Mon, 18 Jun 2018 08:43:22 +0200
26ba25
Subject: [PATCH 024/268] block-qdict: Simplify qdict_flatten_qdict()
26ba25
26ba25
RH-Author: Markus Armbruster <armbru@redhat.com>
26ba25
Message-id: <20180618084330.30009-16-armbru@redhat.com>
26ba25
Patchwork-id: 80723
26ba25
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 15/23] block-qdict: Simplify qdict_flatten_qdict()
26ba25
Bugzilla: 1557995
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
26ba25
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
26ba25
26ba25
There's no need to restart the loop.  We don't elsewhere, e.g. in
26ba25
qdict_extract_subqdict(), qdict_join() and qemu_opts_absorb_qdict().
26ba25
Simplify accordingly.
26ba25
26ba25
Signed-off-by: Markus Armbruster <armbru@redhat.com>
26ba25
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
(cherry picked from commit eb0e0f7d3d4a9c585421d05b19ca71df5d69fc47)
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 qobject/block-qdict.c | 18 +++---------------
26ba25
 1 file changed, 3 insertions(+), 15 deletions(-)
26ba25
26ba25
diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c
26ba25
index 41f39ab..f32df34 100644
26ba25
--- a/qobject/block-qdict.c
26ba25
+++ b/qobject/block-qdict.c
26ba25
@@ -89,16 +89,13 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix)
26ba25
     QObject *value;
26ba25
     const QDictEntry *entry, *next;
26ba25
     char *new_key;
26ba25
-    bool delete;
26ba25
 
26ba25
     entry = qdict_first(qdict);
26ba25
 
26ba25
     while (entry != NULL) {
26ba25
-
26ba25
         next = qdict_next(qdict, entry);
26ba25
         value = qdict_entry_value(entry);
26ba25
         new_key = NULL;
26ba25
-        delete = false;
26ba25
 
26ba25
         if (prefix) {
26ba25
             new_key = g_strdup_printf("%s.%s", prefix, entry->key);
26ba25
@@ -109,27 +106,18 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix)
26ba25
              * itself disappears. */
26ba25
             qdict_flatten_qdict(qobject_to(QDict, value), target,
26ba25
                                 new_key ? new_key : entry->key);
26ba25
-            delete = true;
26ba25
+            qdict_del(qdict, entry->key);
26ba25
         } else if (qobject_type(value) == QTYPE_QLIST) {
26ba25
             qdict_flatten_qlist(qobject_to(QList, value), target,
26ba25
                                 new_key ? new_key : entry->key);
26ba25
-            delete = true;
26ba25
+            qdict_del(qdict, entry->key);
26ba25
         } else if (prefix) {
26ba25
             /* All other objects are moved to the target unchanged. */
26ba25
             qdict_put_obj(target, new_key, qobject_ref(value));
26ba25
-            delete = true;
26ba25
-        }
26ba25
-
26ba25
-        g_free(new_key);
26ba25
-
26ba25
-        if (delete) {
26ba25
             qdict_del(qdict, entry->key);
26ba25
-
26ba25
-            /* Restart loop after modifying the iterated QDict */
26ba25
-            entry = qdict_first(qdict);
26ba25
-            continue;
26ba25
         }
26ba25
 
26ba25
+        g_free(new_key);
26ba25
         entry = next;
26ba25
     }
26ba25
 }
26ba25
-- 
26ba25
1.8.3.1
26ba25