[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 24/43] qemu-option: qemu_opts_validate(): fix duplic
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 24/43] qemu-option: qemu_opts_validate(): fix duplicated code |
Date: |
Thu, 13 Dec 2012 16:10:31 +0100 |
From: Dong Xu Wang <address@hidden>
Use opts_accepts_any() and find_desc_by_name().
Signed-off-by: Luiz Capitulino <address@hidden>
Signed-off-by: Dong Xu Wang <address@hidden>
Signed-off-by: Kevin Wolf <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.6.5
- [Qemu-devel] [PATCH 33/43] qcow2: Move BLKDBG_EVENT out of the lock, (continued)
- [Qemu-devel] [PATCH 33/43] qcow2: Move BLKDBG_EVENT out of the lock, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 41/43] qcow2: Enable dirty flag in qcow2_alloc_cluster_link_l2, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 39/43] qcow2: Drop l2meta.cluster_offset, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 31/43] blkdebug: Implement suspend/resume of AIO requests, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 20/43] qemu-io: Implement write -c for compressed clusters, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 26/43] introduce qemu_opts_create_nofail function, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 29/43] blkdebug: Allow usage without config file, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 15/43] qemu-img: img_create(): drop unneeded goto and ret variable, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 21/43] rbd: Fix race between aio completition and aio cancel, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 19/43] tests: Add tests for fdsets, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 24/43] qemu-option: qemu_opts_validate(): fix duplicated code,
Kevin Wolf <=
- [Qemu-devel] [PATCH 42/43] qcow2: Execute run_dependent_requests() without lock, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 38/43] qcow2: Allocate l2meta dynamically, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 40/43] qcow2: Allocate l2meta only for cluster allocations, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 36/43] qcow2: Round QCowL2Meta.offset down to cluster boundary, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 34/43] qemu-iotests: Test concurrent cluster allocations, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 37/43] qcow2: Introduce Qcow2COWRegion, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 25/43] qemu-option: qemu_opt_set_bool(): fix code duplication, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 18/43] block: bdrv_img_create(): drop unused error handling code, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 32/43] qemu-io: Add AIO debugging commands, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 28/43] create new function: qemu_opt_set_number, Kevin Wolf, 2012/12/13