[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 13/18] block-qdict: Simplify qdict_is_list() some
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH v2 13/18] block-qdict: Simplify qdict_is_list() some |
Date: |
Thu, 14 Jun 2018 21:14:38 +0200 |
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
---
qobject/block-qdict.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c
index 36cf58acc8..e51a3d2c0f 100644
--- a/qobject/block-qdict.c
+++ b/qobject/block-qdict.c
@@ -317,27 +317,22 @@ static int qdict_is_list(QDict *maybe_list, Error **errp)
for (ent = qdict_first(maybe_list); ent != NULL;
ent = qdict_next(maybe_list, ent)) {
+ int is_index = !qemu_strtoi64(ent->key, NULL, 10, &val);
- if (qemu_strtoi64(ent->key, NULL, 10, &val) == 0) {
- if (is_list == -1) {
- is_list = 1;
- } else if (!is_list) {
- error_setg(errp,
- "Cannot mix list and non-list keys");
- return -1;
- }
+ if (is_list == -1) {
+ is_list = is_index;
+ }
+
+ if (is_index != is_list) {
+ error_setg(errp, "Cannot mix list and non-list keys");
+ return -1;
+ }
+
+ if (is_index) {
len++;
if (val > max) {
max = val;
}
- } else {
- if (is_list == -1) {
- is_list = 0;
- } else if (is_list) {
- error_setg(errp,
- "Cannot mix list and non-list keys");
- return -1;
- }
}
}
--
2.17.1
- [Qemu-devel] [PATCH v2 00/18] block: Configuration fixes and rbd authentication, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 01/18] rbd: Drop deprecated -drive parameter "filename", Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 12/18] block-qdict: Clean up qdict_crumple() a bit, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 02/18] iscsi: Drop deprecated -drive parameter "filename", Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 14/18] check-block-qdict: Rename qdict_flatten()'s variables for clarity, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 09/18] block: Make remaining uses of qobject input visitor more robust, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 11/18] block-qdict: Tweak qdict_flatten_qdict(), qdict_flatten_qlist(), Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 18/18] rbd: New parameter key-secret, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 03/18] block: Add block-specific QDict header, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 13/18] block-qdict: Simplify qdict_is_list() some,
Markus Armbruster <=
- [Qemu-devel] [PATCH v2 15/18] check-block-qdict: Cover flattening of empty lists and dictionaries, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 10/18] block-qdict: Simplify qdict_flatten_qdict(), Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 07/18] block: Clean up a misuse of qobject_to() in .bdrv_co_create_opts(), Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 08/18] block: Factor out qobject_input_visitor_new_flat_confused(), Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 16/18] block: Fix -blockdev / blockdev-add for empty objects and arrays, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 17/18] rbd: New parameter auth-client-required, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 06/18] block: Fix -drive for certain non-string scalars, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 05/18] block: Fix -blockdev for certain non-string scalars, Markus Armbruster, 2018/06/14
- [Qemu-devel] [PATCH v2 04/18] qobject: Move block-specific qdict code to block-qdict.c, Markus Armbruster, 2018/06/14
- Re: [Qemu-devel] [PATCH v2 00/18] block: Configuration fixes and rbd authentication, Kevin Wolf, 2018/06/15