[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/21] qdict: Make qdict_extract_subqdict() accept ds
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 16/21] qdict: Make qdict_extract_subqdict() accept dst = NULL |
Date: |
Wed, 15 Aug 2018 14:55:32 +0200 |
From: Alberto Garcia <address@hidden>
This function extracts all options from a QDict starting with a
certain prefix and puts them in a new QDict.
We'll have a couple of cases where we simply want to discard those
options instead of copying them, and that's what this patch does.
Signed-off-by: Alberto Garcia <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qobject/block-qdict.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c
index 80c653013f..42054cc274 100644
--- a/qobject/block-qdict.c
+++ b/qobject/block-qdict.c
@@ -158,20 +158,25 @@ void qdict_flatten(QDict *qdict)
qdict_flatten_qdict(qdict, qdict, NULL);
}
-/* extract all the src QDict entries starting by start into dst */
+/* extract all the src QDict entries starting by start into dst.
+ * If dst is NULL then the entries are simply removed from src. */
void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start)
{
const QDictEntry *entry, *next;
const char *p;
- *dst = qdict_new();
+ if (dst) {
+ *dst = qdict_new();
+ }
entry = qdict_first(src);
while (entry != NULL) {
next = qdict_next(src, entry);
if (strstart(entry->key, start, &p)) {
- qdict_put_obj(*dst, p, qobject_ref(entry->value));
+ if (dst) {
+ qdict_put_obj(*dst, p, qobject_ref(entry->value));
+ }
qdict_del(src, entry->key);
}
entry = next;
--
2.13.6
- [Qemu-devel] [PULL 11/21] qapi/block: Document restrictions for node names, (continued)
- [Qemu-devel] [PULL 11/21] qapi/block: Document restrictions for node names, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 09/21] block: Remove deprecated -drive option serial, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 17/21] block: Remove children options from bs->{options, explicit_options}, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 12/21] mirror: Fail gracefully for source == target, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 21/21] qapi: block: Remove mentions of error types which were removed, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 10/21] block: Remove dead deprecation warning code, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 20/21] block: Simplify append_open_options(), Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 19/21] block: Update bs->options if bdrv_reopen() succeeds, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 14/21] block: make .bdrv_close optional, Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 18/21] block: Simplify bdrv_reopen_abort(), Kevin Wolf, 2018/08/15
- [Qemu-devel] [PULL 16/21] qdict: Make qdict_extract_subqdict() accept dst = NULL,
Kevin Wolf <=
- [Qemu-devel] [PULL 08/21] block: Remove deprecated -drive option addr, Kevin Wolf, 2018/08/15
- Re: [Qemu-devel] [PULL 00/21] Block layer patches, Peter Maydell, 2018/08/16