diff options
author | Markus Armbruster <armbru@redhat.com> | 2020-07-07 18:05:38 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-07-10 15:01:06 +0200 |
commit | 44b0b7d1758d105cea2d6156a071e8d9e2256f69 (patch) | |
tree | fc806b402ef18941655b62fddc78ff160bf67ee0 | |
parent | f23db652cb87cfb9aacc7cfd92ea01c00ca0162b (diff) |
qemu-option: Simplify around find_default_by_name()
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-11-armbru@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
-rw-r--r-- | util/qemu-option.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/util/qemu-option.c b/util/qemu-option.c index 14e211ddd8..e7b540a21b 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -277,7 +277,6 @@ static void qemu_opt_del_all(QemuOpts *opts, const char *name) const char *qemu_opt_get(QemuOpts *opts, const char *name) { QemuOpt *opt; - const char *def_val; if (opts == NULL) { return NULL; @@ -285,12 +284,10 @@ const char *qemu_opt_get(QemuOpts *opts, const char *name) opt = qemu_opt_find(opts, name); if (!opt) { - def_val = find_default_by_name(opts, name); - if (def_val) { - return def_val; - } + return find_default_by_name(opts, name); } - return opt ? opt->str : NULL; + + return opt->str; } void qemu_opt_iter_init(QemuOptsIter *iter, QemuOpts *opts, const char *name) @@ -319,8 +316,7 @@ const char *qemu_opt_iter_next(QemuOptsIter *iter) char *qemu_opt_get_del(QemuOpts *opts, const char *name) { QemuOpt *opt; - const char *def_val; - char *str = NULL; + char *str; if (opts == NULL) { return NULL; @@ -328,11 +324,7 @@ char *qemu_opt_get_del(QemuOpts *opts, const char *name) opt = qemu_opt_find(opts, name); if (!opt) { - def_val = find_default_by_name(opts, name); - if (def_val) { - str = g_strdup(def_val); - } - return str; + return g_strdup(find_default_by_name(opts, name)); } str = opt->str; opt->str = NULL; |