summaryrefslogtreecommitdiff
path: root/qemu-option.c
diff options
context:
space:
mode:
authorDong Xu Wang <wdongxu@linux.vnet.ibm.com>2012-12-06 14:47:19 +0800
committerKevin Wolf <kwolf@redhat.com>2012-12-11 16:30:22 +0100
commitdb97ceba1e17db59188e91b66e61bf84a6a71081 (patch)
tree81a9b962c17eeb3174ba34a5ef94324e088db498 /qemu-option.c
parentc474ced8fe6684265fbb6a3183eb0cbea561409f (diff)
downloadqemu-db97ceba1e17db59188e91b66e61bf84a6a71081.tar.gz
qemu-option: qemu_opts_validate(): fix duplicated code
Use opts_accepts_any() and find_desc_by_name(). Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-option.c')
-rw-r--r--qemu-option.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/qemu-option.c b/qemu-option.c
index 375daaa4ad..74321bbc13 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);