From: Peter Krempa Date: Tue, 6 Dec 2022 14:29:28 +0000 (+0100) Subject: qemu_monitor_json: Replace simplify fetching Array from JSON object X-Git-Tag: v9.1.0-rc1~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d05a04821ff93b21dfa777a22701ecda3015201;p=thirdparty%2Flibvirt.git qemu_monitor_json: Replace simplify fetching Array from JSON object Replace instances of virJSONValueObjectGet + virJSONValueIsArray by virJSONValueObjectGetArray. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 01e2aaa2cf..d05ca2932f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -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");