提交 c78b8cfb 编写于 作者: M Markus Armbruster 提交者: Kevin Wolf

block-qdict: Simplify qdict_is_list() some

Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Reviewed-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 3692b5d7
...@@ -317,27 +317,22 @@ static int qdict_is_list(QDict *maybe_list, Error **errp) ...@@ -317,27 +317,22 @@ static int qdict_is_list(QDict *maybe_list, Error **errp)
for (ent = qdict_first(maybe_list); ent != NULL; for (ent = qdict_first(maybe_list); ent != NULL;
ent = qdict_next(maybe_list, ent)) { 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) {
if (is_list == -1) { is_list = is_index;
is_list = 1; }
} else if (!is_list) {
error_setg(errp, if (is_index != is_list) {
"Cannot mix list and non-list keys"); error_setg(errp, "Cannot mix list and non-list keys");
return -1; return -1;
} }
if (is_index) {
len++; len++;
if (val > max) { if (val > max) {
max = val; 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;
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册