[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 14/46] qemu-option: Factor out helper opt_create()
From: |
Markus Armbruster |
Subject: |
[PATCH 14/46] qemu-option: Factor out helper opt_create() |
Date: |
Wed, 24 Jun 2020 18:43:12 +0200 |
There is just one use so far. The next commit will add more.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
util/qemu-option.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/util/qemu-option.c b/util/qemu-option.c
index d9293814b4..3cdf0c0800 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -502,6 +502,23 @@ int qemu_opt_unset(QemuOpts *opts, const char *name)
}
}
+static QemuOpt *opt_create(QemuOpts *opts, const char *name, char *value,
+ bool prepend)
+{
+ QemuOpt *opt = g_malloc0(sizeof(*opt));
+
+ opt->name = g_strdup(name);
+ opt->str = value;
+ opt->opts = opts;
+ if (prepend) {
+ QTAILQ_INSERT_HEAD(&opts->head, opt, next);
+ } else {
+ QTAILQ_INSERT_TAIL(&opts->head, opt, next);
+ }
+
+ return opt;
+}
+
static void opt_set(QemuOpts *opts, const char *name, char *value,
bool prepend, bool *help_wanted, Error **errp)
{
@@ -519,16 +536,8 @@ static void opt_set(QemuOpts *opts, const char *name, char
*value,
return;
}
- opt = g_malloc0(sizeof(*opt));
- opt->name = g_strdup(name);
- opt->opts = opts;
- if (prepend) {
- QTAILQ_INSERT_HEAD(&opts->head, opt, next);
- } else {
- QTAILQ_INSERT_TAIL(&opts->head, opt, next);
- }
+ opt = opt_create(opts, name, value, prepend);
opt->desc = desc;
- opt->str = value;
qemu_opt_parse(opt, &local_err);
if (local_err) {
error_propagate(errp, local_err);
--
2.26.2
- Re: [PATCH 02/46] error: Document Error API usage rules, (continued)
Re: [PATCH 02/46] error: Document Error API usage rules, Greg Kurz, 2020/06/25
[PATCH 12/46] qemu-option: Factor out helper find_default_by_name(), Markus Armbruster, 2020/06/24
[PATCH 09/46] error: Avoid error_propagate() after migrate_add_blocker(), Markus Armbruster, 2020/06/24
[PATCH 14/46] qemu-option: Factor out helper opt_create(),
Markus Armbruster <=
[PATCH 04/46] macio: Tidy up error handling in macio_newworld_realize(), Markus Armbruster, 2020/06/24
[PATCH 15/46] qemu-option: Tidy up opt_set() not to free arguments on failure, Markus Armbruster, 2020/06/24
[PATCH 06/46] error: Avoid error_propagate() when error is not used here, Markus Armbruster, 2020/06/24