mirror of
https://github.com/mii443/qemu.git
synced 2025-12-16 17:18:49 +00:00
QemuOpts: Drop qemu_opts_foreach() parameter abort_on_failure
When the argument is non-zero, qemu_opts_foreach() stops on callback returning non-zero, and returns that value. When the argument is zero, it doesn't stop, and returns the bit-wise inclusive or of all the return values. Funky :) The callers that pass zero could just as well pass one, because their callbacks can't return anything but zero: * qemu_add_globals()'s callback qdev_add_one_global() * qemu_config_write()'s callback config_write_opts() * main()'s callbacks default_driver_check(), drive_enable_snapshot(), vnc_init_func() Drop the parameter, and always stop. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
@@ -1046,22 +1046,29 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque,
|
||||
int abort_on_failure)
|
||||
/**
|
||||
* For each member of @list, call @func(member, @opaque).
|
||||
* Call it with the current location temporarily set to the member's.
|
||||
* When @func() returns non-zero, break the loop and return that value.
|
||||
* Return zero when the loop completes.
|
||||
*/
|
||||
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
|
||||
void *opaque)
|
||||
{
|
||||
Location loc;
|
||||
QemuOpts *opts;
|
||||
int rc = 0;
|
||||
int rc;
|
||||
|
||||
loc_push_none(&loc);
|
||||
QTAILQ_FOREACH(opts, &list->head, next) {
|
||||
loc_restore(&opts->loc);
|
||||
rc |= func(opts, opaque);
|
||||
if (abort_on_failure && rc != 0)
|
||||
break;
|
||||
rc = func(opts, opaque);
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
loc_pop(&loc);
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t count_opts_list(QemuOptsList *list)
|
||||
|
||||
Reference in New Issue
Block a user