Blame SOURCES/kvm-block-qdict-Simplify-qdict_is_list-some.patch

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