Blame SOURCES/kvm-block-qdict-Simplify-qdict_flatten_qdict.patch

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