thebeanogamer / rpms / qemu-kvm

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