aboutsummaryrefslogtreecommitdiff
path: root/util/qemu-option.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-07-07 18:05:42 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-07-10 15:17:35 +0200
commit235e59cf03ed75d0ce96c97343194ed11c146231 (patch)
treec2de9b6a66355d038fe4ccb4d79de13905101b52 /util/qemu-option.c
parentc75d7f71918b8497a710f3f2b646567c09db3770 (diff)
downloadqemu-235e59cf03ed75d0ce96c97343194ed11c146231.zip
qemu-235e59cf03ed75d0ce96c97343194ed11c146231.tar.gz
qemu-235e59cf03ed75d0ce96c97343194ed11c146231.tar.bz2
qemu-option: Use returned bool to check for failure
The previous commit enables conversion of foo(..., &err); if (err) { ... } to if (!foo(..., &err)) { ... } for QemuOpts functions that now return true / false on success / error. Coccinelle script: @@ identifier fun = { opts_do_parse, parse_option_bool, parse_option_number, parse_option_size, qemu_opt_parse, qemu_opt_rename, qemu_opt_set, qemu_opt_set_bool, qemu_opt_set_number, qemu_opts_absorb_qdict, qemu_opts_do_parse, qemu_opts_from_qdict_entry, qemu_opts_set, qemu_opts_validate }; expression list args, args2; typedef Error; Error *err; @@ - fun(args, &err, args2); - if (err) + if (!fun(args, &err, args2)) { ... } A few line breaks tidied up manually. 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-15-armbru@redhat.com> [Conflict with commit 0b6786a9c1 "block/amend: refactor qcow2 amend options" resolved by rerunning Coccinelle on master's version]
Diffstat (limited to 'util/qemu-option.c')
-rw-r--r--util/qemu-option.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 2f4fb62..1dd14a0 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -536,8 +536,7 @@ static bool opt_validate(QemuOpt *opt, bool *help_wanted,
}
opt->desc = desc;
- qemu_opt_parse(opt, &local_err);
- if (local_err) {
+ if (!qemu_opt_parse(opt, &local_err)) {
error_propagate(errp, local_err);
return false;
}
@@ -929,8 +928,8 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
return NULL;
}
- opts_do_parse(opts, params, firstname, defaults, help_wanted, &local_err);
- if (local_err) {
+ if (!opts_do_parse(opts, params, firstname, defaults, help_wanted,
+ &local_err)) {
error_propagate(errp, local_err);
qemu_opts_del(opts);
return NULL;
@@ -1045,8 +1044,7 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
for (entry = qdict_first(qdict);
entry;
entry = qdict_next(qdict, entry)) {
- qemu_opts_from_qdict_entry(opts, entry, &local_err);
- if (local_err) {
+ if (!qemu_opts_from_qdict_entry(opts, entry, &local_err)) {
error_propagate(errp, local_err);
qemu_opts_del(opts);
return NULL;
@@ -1073,8 +1071,7 @@ bool qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)
next = qdict_next(qdict, entry);
if (find_desc_by_name(opts->list->desc, entry->key)) {
- qemu_opts_from_qdict_entry(opts, entry, &local_err);
- if (local_err) {
+ if (!qemu_opts_from_qdict_entry(opts, entry, &local_err)) {
error_propagate(errp, local_err);
return false;
}
@@ -1158,8 +1155,7 @@ bool qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
return false;
}
- qemu_opt_parse(opt, &local_err);
- if (local_err) {
+ if (!qemu_opt_parse(opt, &local_err)) {
error_propagate(errp, local_err);
return false;
}