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

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