thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ae23c9
From f4dbafc267d6ae5a1c359a026b87d4d423e5f607 Mon Sep 17 00:00:00 2001
ae23c9
From: Markus Armbruster <armbru@redhat.com>
ae23c9
Date: Mon, 18 Jun 2018 08:43:25 +0200
ae23c9
Subject: [PATCH 027/268] block-qdict: Simplify qdict_is_list() some
ae23c9
ae23c9
RH-Author: Markus Armbruster <armbru@redhat.com>
ae23c9
Message-id: <20180618084330.30009-19-armbru@redhat.com>
ae23c9
Patchwork-id: 80741
ae23c9
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 18/23] block-qdict: Simplify qdict_is_list() some
ae23c9
Bugzilla: 1557995
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
ae23c9
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
ae23c9
Signed-off-by: Markus Armbruster <armbru@redhat.com>
ae23c9
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
(cherry picked from commit c78b8cfbfd53737353dc94dfb99c57d72ce31ab5)
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 qobject/block-qdict.c | 27 +++++++++++----------------
ae23c9
 1 file changed, 11 insertions(+), 16 deletions(-)
ae23c9
ae23c9
diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c
ae23c9
index 36cf58a..e51a3d2 100644
ae23c9
--- a/qobject/block-qdict.c
ae23c9
+++ b/qobject/block-qdict.c
ae23c9
@@ -317,27 +317,22 @@ static int qdict_is_list(QDict *maybe_list, Error **errp)
ae23c9
 
ae23c9
     for (ent = qdict_first(maybe_list); ent != NULL;
ae23c9
          ent = qdict_next(maybe_list, ent)) {
ae23c9
+        int is_index = !qemu_strtoi64(ent->key, NULL, 10, &val;;
ae23c9
 
ae23c9
-        if (qemu_strtoi64(ent->key, NULL, 10, &val) == 0) {
ae23c9
-            if (is_list == -1) {
ae23c9
-                is_list = 1;
ae23c9
-            } else if (!is_list) {
ae23c9
-                error_setg(errp,
ae23c9
-                           "Cannot mix list and non-list keys");
ae23c9
-                return -1;
ae23c9
-            }
ae23c9
+        if (is_list == -1) {
ae23c9
+            is_list = is_index;
ae23c9
+        }
ae23c9
+
ae23c9
+        if (is_index != is_list) {
ae23c9
+            error_setg(errp, "Cannot mix list and non-list keys");
ae23c9
+            return -1;
ae23c9
+        }
ae23c9
+
ae23c9
+        if (is_index) {
ae23c9
             len++;
ae23c9
             if (val > max) {
ae23c9
                 max = val;
ae23c9
             }
ae23c9
-        } else {
ae23c9
-            if (is_list == -1) {
ae23c9
-                is_list = 0;
ae23c9
-            } else if (is_list) {
ae23c9
-                error_setg(errp,
ae23c9
-                           "Cannot mix list and non-list keys");
ae23c9
-                return -1;
ae23c9
-            }
ae23c9
         }
ae23c9
     }
ae23c9
 
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9