|
|
ae23c9 |
From c756588134a48f4d1e33c62117aadc749544c5e7 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
Date: Mon, 18 Jun 2018 08:43:23 +0200
|
|
|
ae23c9 |
Subject: [PATCH 025/268] block-qdict: Tweak qdict_flatten_qdict(),
|
|
|
ae23c9 |
qdict_flatten_qlist()
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180618084330.30009-17-armbru@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 80725
|
|
|
ae23c9 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 16/23] block-qdict: Tweak qdict_flatten_qdict(), qdict_flatten_qlist()
|
|
|
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 |
qdict_flatten_qdict() skips copying scalars from @qdict to @target
|
|
|
ae23c9 |
when the two are the same. Fair enough, but it uses a non-obvious
|
|
|
ae23c9 |
test for "same". Replace it by the obvious one. While there, improve
|
|
|
ae23c9 |
comments.
|
|
|
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 f1b34a248e9785e8cc0d28a1685d2cf4460bb256)
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
qobject/block-qdict.c | 14 +++++++++-----
|
|
|
ae23c9 |
1 file changed, 9 insertions(+), 5 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c
|
|
|
ae23c9 |
index f32df34..a4e1c8d 100644
|
|
|
ae23c9 |
--- a/qobject/block-qdict.c
|
|
|
ae23c9 |
+++ b/qobject/block-qdict.c
|
|
|
ae23c9 |
@@ -71,12 +71,15 @@ static void qdict_flatten_qlist(QList *qlist, QDict *target, const char *prefix)
|
|
|
ae23c9 |
value = qlist_entry_obj(entry);
|
|
|
ae23c9 |
new_key = g_strdup_printf("%s.%i", prefix, i);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+ /*
|
|
|
ae23c9 |
+ * Flatten non-empty QDict and QList recursively into @target,
|
|
|
ae23c9 |
+ * copy other objects to @target
|
|
|
ae23c9 |
+ */
|
|
|
ae23c9 |
if (qobject_type(value) == QTYPE_QDICT) {
|
|
|
ae23c9 |
qdict_flatten_qdict(qobject_to(QDict, value), target, new_key);
|
|
|
ae23c9 |
} else if (qobject_type(value) == QTYPE_QLIST) {
|
|
|
ae23c9 |
qdict_flatten_qlist(qobject_to(QList, value), target, new_key);
|
|
|
ae23c9 |
} else {
|
|
|
ae23c9 |
- /* All other types are moved to the target unchanged. */
|
|
|
ae23c9 |
qdict_put_obj(target, new_key, qobject_ref(value));
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -101,9 +104,11 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix)
|
|
|
ae23c9 |
new_key = g_strdup_printf("%s.%s", prefix, entry->key);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+ /*
|
|
|
ae23c9 |
+ * Flatten non-empty QDict and QList recursively into @target,
|
|
|
ae23c9 |
+ * copy other objects to @target
|
|
|
ae23c9 |
+ */
|
|
|
ae23c9 |
if (qobject_type(value) == QTYPE_QDICT) {
|
|
|
ae23c9 |
- /* Entries of QDicts are processed recursively, the QDict object
|
|
|
ae23c9 |
- * itself disappears. */
|
|
|
ae23c9 |
qdict_flatten_qdict(qobject_to(QDict, value), target,
|
|
|
ae23c9 |
new_key ? new_key : entry->key);
|
|
|
ae23c9 |
qdict_del(qdict, entry->key);
|
|
|
ae23c9 |
@@ -111,8 +116,7 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix)
|
|
|
ae23c9 |
qdict_flatten_qlist(qobject_to(QList, value), target,
|
|
|
ae23c9 |
new_key ? new_key : entry->key);
|
|
|
ae23c9 |
qdict_del(qdict, entry->key);
|
|
|
ae23c9 |
- } else if (prefix) {
|
|
|
ae23c9 |
- /* All other objects are moved to the target unchanged. */
|
|
|
ae23c9 |
+ } else if (target != qdict) {
|
|
|
ae23c9 |
qdict_put_obj(target, new_key, qobject_ref(value));
|
|
|
ae23c9 |
qdict_del(qdict, entry->key);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|