summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-03-12 07:45:10 +0100
committerMarkus Armbruster <armbru@redhat.com>2015-06-09 07:40:23 +0200
commit1640b200d53e3d981f12a192fe84b7bb7958c065 (patch)
treebea7e4594fee170e218d8b83d43815649551a4b4 /util
parent8809cfc38e4e93884d664bb00108fc71b423f589 (diff)
downloadqemu-1640b200d53e3d981f12a192fe84b7bb7958c065.zip
QemuOpts: Drop qemu_opt_foreach() parameter abort_on_failure
When the argument is non-zero, qemu_opt_foreach() stops on callback returning non-zero, and returns that value. When the argument is zero, it doesn't stop, and returns the callback's value from the last iteration. The two callers that pass zero could just as well pass one: * qemu_spice_init()'s callback add_channel() either returns zero or exit()s. * config_write_opts()'s callback config_write_opt() always returns zero. Drop the parameter, and always stop. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/qemu-config.c2
-rw-r--r--util/qemu-option.c17
2 files changed, 12 insertions, 7 deletions
diff --git a/util/qemu-config.c b/util/qemu-config.c
index a88461f6b7..aff4cb37c0 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -353,7 +353,7 @@ static int config_write_opts(void *opaque, QemuOpts *opts, Error **errp)
} else {
fprintf(data->fp, "[%s]\n", data->list->name);
}
- qemu_opt_foreach(opts, config_write_opt, data, 0);
+ qemu_opt_foreach(opts, config_write_opt, data);
fprintf(data->fp, "\n");
return 0;
}
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 07b03e313a..296e2b3fae 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -596,18 +596,23 @@ void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
QTAILQ_INSERT_TAIL(&opts->head, opt, next);
}
-int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
- int abort_on_failure)
+/**
+ * For each member of @opts, call @func(name, value, @opaque).
+ * When @func() returns non-zero, break the loop and return that value.
+ * Return zero when the loop completes.
+ */
+int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque)
{
QemuOpt *opt;
- int rc = 0;
+ int rc;
QTAILQ_FOREACH(opt, &opts->head, next) {
rc = func(opt->name, opt->str, opaque);
- if (abort_on_failure && rc != 0)
- break;
+ if (rc) {
+ return rc;
+ }
}
- return rc;
+ return 0;
}
QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)