mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00
QemuOpts: Convert qemu_opt_foreach() to Error
Retain the function value for now, to permit selective conversion of its callers. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
1640b200d5
commit
71df1d8337
7 changed files with 29 additions and 18 deletions
|
@ -597,20 +597,23 @@ void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
|
|||
}
|
||||
|
||||
/**
|
||||
* For each member of @opts, call @func(name, value, @opaque).
|
||||
* For each member of @opts, call @func(@opaque, name, value, @errp).
|
||||
* @func() may store an Error through @errp, but must return non-zero then.
|
||||
* 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)
|
||||
int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
|
||||
Error **errp)
|
||||
{
|
||||
QemuOpt *opt;
|
||||
int rc;
|
||||
|
||||
QTAILQ_FOREACH(opt, &opts->head, next) {
|
||||
rc = func(opt->name, opt->str, opaque);
|
||||
rc = func(opaque, opt->name, opt->str, errp);
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
assert(!errp || !*errp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue