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

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