From patchwork Thu Dec 6 06:47:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [V7,02/10] qemu-option: qemu_opts_validate(): fix duplicated code Date: Wed, 05 Dec 2012 20:47:19 -0000 From: Robert Wang X-Patchwork-Id: 204148 Message-Id: <1354776447-12041-3-git-send-email-wdongxu@linux.vnet.ibm.com> To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, Dong Xu Wang , Luiz Capitulino Use opts_accepts_any() and find_desc_by_name(). Signed-off-by: Luiz Capitulino Signed-off-by: Dong Xu Wang --- qemu-option.c | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-) diff --git a/qemu-option.c b/qemu-option.c index 375daaa..74321bb 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);