]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_monitor_json: Replace simplify fetching Array from JSON object
authorPeter Krempa <pkrempa@redhat.com>
Tue, 6 Dec 2022 14:29:28 +0000 (15:29 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 6 Feb 2023 12:34:06 +0000 (13:34 +0100)
Replace instances of virJSONValueObjectGet + virJSONValueIsArray by
virJSONValueObjectGetArray.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor_json.c

index 01e2aaa2cfe57b69095da994be944eb5bd32ad8b..d05ca2932ff00cb499d495ff0180d21663f0cec7 100644 (file)
@@ -3634,11 +3634,9 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
                          "in query-rx-filter response"));
         return -1;
     }
-    if ((!(table = virJSONValueObjectGet(entry, "unicast-table"))) ||
-        (!virJSONValueIsArray(table))) {
+    if ((!(table = virJSONValueObjectGetArray(entry, "unicast-table")))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Missing or invalid 'unicast-table' array "
-                         "in query-rx-filter response"));
+                       _("Missing or invalid 'unicast-table' array in query-rx-filter response"));
         return -1;
     }
     nTable = virJSONValueArraySize(table);
@@ -3675,11 +3673,9 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
                          "in query-rx-filter response"));
         return -1;
     }
-    if ((!(table = virJSONValueObjectGet(entry, "multicast-table"))) ||
-        (!virJSONValueIsArray(table))) {
+    if ((!(table = virJSONValueObjectGetArray(entry, "multicast-table")))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Missing or invalid 'multicast-table' array "
-                         "in query-rx-filter response"));
+                       _("Missing or invalid 'multicast-table' array in query-rx-filter response"));
         return -1;
     }
     nTable = virJSONValueArraySize(table);
@@ -3709,11 +3705,9 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
                          "in query-rx-filter response"));
         return -1;
     }
-    if ((!(table = virJSONValueObjectGet(entry, "vlan-table"))) ||
-        (!virJSONValueIsArray(table))) {
+    if ((!(table = virJSONValueObjectGetArray(entry, "vlan-table")))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Missing or invalid 'vlan-table' array "
-                         "in query-rx-filter response"));
+                       _("Missing or invalid 'vlan-table' array in query-rx-filter response"));
         return -1;
     }
     nTable = virJSONValueArraySize(table);
@@ -8722,9 +8716,7 @@ qemuMonitorJSONExtractQueryStatsSchema(virJSONValue *json)
         if (!virJSONValueIsObject(obj))
             continue;
 
-        stats = virJSONValueObjectGetArray(obj, "stats");
-
-        if (!virJSONValueIsArray(stats))
+        if (!(stats = virJSONValueObjectGetArray(obj, "stats")))
             continue;
 
         target_str = virJSONValueObjectGetString(obj, "target");