[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V7 02/10] qemu-option: qemu_opts_validate(): fix dup
From: |
Dong Xu Wang |
Subject: |
[Qemu-devel] [PATCH V7 02/10] qemu-option: qemu_opts_validate(): fix duplicated code |
Date: |
Thu, 6 Dec 2012 14:47:19 +0800 |
Use opts_accepts_any() and find_desc_by_name().
Signed-off-by: Luiz Capitulino <address@hidden>
Signed-off-by: Dong Xu Wang <address@hidden>
---
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);
--
1.7.1
- [Qemu-devel] [PATCH V7 00/10] replace QEMUOptionParameter with QemuOpts parser, Dong Xu Wang, 2012/12/06
- [Qemu-devel] [PATCH V7 01/10] qemu-option: opt_set(): split it up into more functions, Dong Xu Wang, 2012/12/06
- [Qemu-devel] [PATCH V7 03/10] qemu-option: qemu_opt_set_bool(): fix code duplication, Dong Xu Wang, 2012/12/06
- [Qemu-devel] [PATCH V7 02/10] qemu-option: qemu_opts_validate(): fix duplicated code,
Dong Xu Wang <=
- [Qemu-devel] [PATCH V7 04/10] introduce qemu_opts_create_nofail function, Dong Xu Wang, 2012/12/06
- [Qemu-devel] [PATCH V7 06/10] create new function: qemu_opt_set_number, Dong Xu Wang, 2012/12/06
- [Qemu-devel] [PATCH V7 05/10] use qemu_opts_create_nofail, Dong Xu Wang, 2012/12/06
- [Qemu-devel] [PATCH V7 07/10] add def_print_str and use it in qemu_opts_print., Dong Xu Wang, 2012/12/06
- [Qemu-devel] [PATCH V7 10/10] remove QEMUOptionParameter related functions and struct, Dong Xu Wang, 2012/12/06
- [Qemu-devel] [PATCH V7 08/10] Create four opts list related functions, Dong Xu Wang, 2012/12/06
- [Qemu-devel] [PATCH V7 09/10] Use QemuOpts support in block layer, Dong Xu Wang, 2012/12/06
- Re: [Qemu-devel] [PATCH V7 00/10] replace QEMUOptionParameter with QemuOpts parser, Stefan Hajnoczi, 2012/12/11