[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-5.1 5/5] qemu-option: Clean up after the previous commit
From: |
Markus Armbruster |
Subject: |
[PATCH for-5.1 5/5] qemu-option: Clean up after the previous commit |
Date: |
Wed, 15 Apr 2020 10:30:48 +0200 |
Signed-off-by: Markus Armbruster <address@hidden>
---
util/qemu-option.c | 43 +++++++++++++++----------------------------
1 file changed, 15 insertions(+), 28 deletions(-)
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 3fabfd157d..123c52bf07 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -967,18 +967,16 @@ void qemu_opts_set_defaults(QemuOptsList *list, const
char *params,
assert(opts);
}
-typedef struct OptsFromQDictState {
- QemuOpts *opts;
- Error **errp;
-} OptsFromQDictState;
-
-static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque)
+static void qemu_opts_from_qdict_entry(QemuOpts *opts,
+ const QDictEntry *entry,
+ Error **errp)
{
- OptsFromQDictState *state = opaque;
+ const char *key = qdict_entry_key(entry);
+ QObject *obj = qdict_entry_value(entry);
char buf[32], *tmp = NULL;
const char *value;
- if (!strcmp(key, "id") || *state->errp) {
+ if (!strcmp(key, "id")) {
return;
}
@@ -999,7 +997,7 @@ static void qemu_opts_from_qdict_1(const char *key, QObject
*obj, void *opaque)
return;
}
- qemu_opt_set(state->opts, key, value, state->errp);
+ qemu_opt_set(opts, key, value, errp);
g_free(tmp);
}
@@ -1012,7 +1010,6 @@ static void qemu_opts_from_qdict_1(const char *key,
QObject *obj, void *opaque)
QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
Error **errp)
{
- OptsFromQDictState state;
Error *local_err = NULL;
QemuOpts *opts;
const QDictEntry *entry;
@@ -1026,20 +1023,15 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list,
const QDict *qdict,
assert(opts != NULL);
- state.errp = &local_err;
- state.opts = opts;
-
for (entry = qdict_first(qdict);
entry;
entry = qdict_next(qdict, entry)) {
- qemu_opts_from_qdict_1(qdict_entry_key(entry),
- qdict_entry_value(entry),
- &state);
- }
- if (local_err) {
- error_propagate(errp, local_err);
- qemu_opts_del(opts);
- return NULL;
+ qemu_opts_from_qdict_entry(opts, entry, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ qemu_opts_del(opts);
+ return NULL;
+ }
}
return opts;
@@ -1058,21 +1050,16 @@ void qemu_opts_absorb_qdict(QemuOpts *opts, QDict
*qdict, Error **errp)
while (entry != NULL) {
Error *local_err = NULL;
- OptsFromQDictState state = {
- .errp = &local_err,
- .opts = opts,
- };
next = qdict_next(qdict, entry);
if (find_desc_by_name(opts->list->desc, entry->key)) {
- qemu_opts_from_qdict_1(entry->key, entry->value, &state);
+ qemu_opts_from_qdict_entry(opts, entry, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
- } else {
- qdict_del(qdict, entry->key);
}
+ qdict_del(qdict, entry->key);
}
entry = next;
--
2.21.1
- [PATCH for-5.1 2/5] qobject: Factor out helper json_pretty_newline(), (continued)
- [PATCH for-5.1 2/5] qobject: Factor out helper json_pretty_newline(), Markus Armbruster, 2020/04/15
- [PATCH for-5.1 1/5] qobject: Clean up QLIST_FOREACH_ENTRY(), Markus Armbruster, 2020/04/15
- [PATCH for-5.1 3/5] qobject: Eliminate qlist_iter(), use QLIST_FOREACH_ENTRY() instead, Markus Armbruster, 2020/04/15
- [PATCH for-5.1 4/5] qobject: Eliminate qdict_iter(), use qdict_first(), qdict_next(), Markus Armbruster, 2020/04/15
- [PATCH for-5.1 5/5] qemu-option: Clean up after the previous commit,
Markus Armbruster <=
- Re: [PATCH for-5.1 0/5] qobject: Minor spring cleaning, Markus Armbruster, 2020/04/29