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