From db97ceba1e17db59188e91b66e61bf84a6a71081 Mon Sep 17 00:00:00 2001 From: Dong Xu Wang Date: Thu, 6 Dec 2012 14:47:19 +0800 Subject: qemu-option: qemu_opts_validate(): fix duplicated code Use opts_accepts_any() and find_desc_by_name(). Signed-off-by: Luiz Capitulino Signed-off-by: Dong Xu Wang Signed-off-by: Kevin Wolf --- qemu-option.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'qemu-option.c') diff --git a/qemu-option.c b/qemu-option.c index 375daaa4a..74321bbc1 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -1076,23 +1076,15 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp) QemuOpt *opt; Error *local_err = NULL; - assert(opts->list->desc[0].name == NULL); + assert(opts_accepts_any(opts)); QTAILQ_FOREACH(opt, &opts->head, next) { - int i; - - for (i = 0; desc[i].name != NULL; i++) { - if (strcmp(desc[i].name, opt->name) == 0) { - break; - } - } - if (desc[i].name == NULL) { + opt->desc = find_desc_by_name(desc, opt->name); + if (!opt->desc) { error_set(errp, QERR_INVALID_PARAMETER, opt->name); return; } - opt->desc = &desc[i]; - qemu_opt_parse(opt, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); -- cgit v1.2.3