]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONGetStringArray: Don't return element count
authorPeter Krempa <pkrempa@redhat.com>
Mon, 14 Jun 2021 14:41:09 +0000 (16:41 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 15 Jun 2021 14:58:23 +0000 (16:58 +0200)
There's just one caller who cares (testQemuMonitorJSONGetTPMModels). Fix
it and remove the counting of elements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_monitor_json.c
tests/qemumonitorjsontest.c

index 74e06e7604961923aa1a00e35cd442df3b5d6827..340d8a1027785c7a4a5184a8366f49863f9790ec 100644 (file)
@@ -7219,7 +7219,7 @@ qemuMonitorJSONGetStringArray(qemuMonitor *mon,
     if (!(*array = virJSONValueObjectGetStringArray(reply, "return")))
         return -1;
 
-    return g_strv_length(*array);
+    return 0;
 }
 
 int qemuMonitorJSONGetTPMModels(qemuMonitor *mon,
index ab589135ba6a0d44a605a69e00c6bb2fd1ff3971..e6746b806fc509413f30aa6a84942d8739696414 100644 (file)
@@ -561,7 +561,6 @@ testQemuMonitorJSONGetTPMModels(const void *opaque)
     const testGenericData *data = opaque;
     virDomainXMLOption *xmlopt = data->xmlopt;
     g_auto(GStrv) tpmmodels = NULL;
-    int ntpmmodels = 0;
     g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
@@ -575,13 +574,12 @@ testQemuMonitorJSONGetTPMModels(const void *opaque)
                                "}") < 0)
         return -1;
 
-    if ((ntpmmodels = qemuMonitorGetTPMModels(qemuMonitorTestGetMonitor(test),
-                                              &tpmmodels)) < 0)
+    if (qemuMonitorGetTPMModels(qemuMonitorTestGetMonitor(test), &tpmmodels) < 0)
         return -1;
 
-    if (ntpmmodels != 1) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "ntpmmodels %d is not 1", ntpmmodels);
+    if (g_strv_length(tpmmodels) != 1) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       "expected 1 tpm model");
         return -1;
     }