[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/53] qemu-option: Factor out helper opt_create()
From: |
Markus Armbruster |
Subject: |
[PULL 11/53] qemu-option: Factor out helper opt_create() |
Date: |
Tue, 7 Jul 2020 23:24:21 +0200 |
There is just one use so far. The next commit will add more.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200707160613.848843-12-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 e7b540a21b..1023fe7527 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -499,6 +499,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)
{
@@ -516,16 +533,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
- [PULL 24/53] qom: Don't handle impossible object_property_get_link() failure, (continued)
- [PULL 24/53] qom: Don't handle impossible object_property_get_link() failure, Markus Armbruster, 2020/07/08
- [PULL 45/53] hmp: Ignore Error objects where the return value suffices, Markus Armbruster, 2020/07/08
- [PULL 16/53] hmp: Eliminate a variable in hmp_migrate_set_parameter(), Markus Armbruster, 2020/07/08
- [PULL 49/53] pflash: Use ERRP_GUARD(), Markus Armbruster, 2020/07/08
- [PULL 30/53] qom: Make functions taking Error ** return bool, not 0/-1, Markus Armbruster, 2020/07/08
- [PULL 46/53] error: New macro ERRP_GUARD(), Markus Armbruster, 2020/07/08
- [PULL 42/53] error: Avoid error_propagate() after migrate_add_blocker(), Markus Armbruster, 2020/07/08
- [PULL 47/53] scripts: Coccinelle script to use ERRP_GUARD(), Markus Armbruster, 2020/07/08
- [PULL 51/53] virtio-9p: Use ERRP_GUARD(), Markus Armbruster, 2020/07/08
- [PULL 13/53] qemu-option: Make functions taking Error ** return bool, not void, Markus Armbruster, 2020/07/08
- [PULL 11/53] qemu-option: Factor out helper opt_create(),
Markus Armbruster <=
- [PULL 34/53] error: Eliminate error_propagate() with Coccinelle, part 1, Markus Armbruster, 2020/07/08
- [PULL 36/53] error: Eliminate error_propagate() manually, Markus Armbruster, 2020/07/08
- [PULL 33/53] error: Avoid unnecessary error_propagate() after error_setg(), Markus Armbruster, 2020/07/08
- [PULL 43/53] qemu-img: Ignore Error objects where the return value suffices, Markus Armbruster, 2020/07/08
- [PULL 31/53] qdev: Make functions taking Error ** return bool, not void, Markus Armbruster, 2020/07/08
- [PULL 23/53] qom: Crash more nicely on object_property_get_link() failure, Markus Armbruster, 2020/07/08
- [PULL 53/53] xen: Use ERRP_GUARD(), Markus Armbruster, 2020/07/08
- [PULL 26/53] qom: Put name parameter before value / visitor parameter, Markus Armbruster, 2020/07/08
- [PULL 40/53] qapi: Smooth visitor error checking in generated code, Markus Armbruster, 2020/07/08
- [PULL 39/53] qapi: Smooth another visitor error checking pattern, Markus Armbruster, 2020/07/08