]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
testQemuMonitorJSONGetTPMModels: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Mon, 14 Jun 2021 14:38:26 +0000 (16:38 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 15 Jun 2021 14:58:23 +0000 (16:58 +0200)
Use automatic memory freeing and remove the cleanup section.t

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

index 5d03f837871a609607af80c46217880fc1440d60..ab589135ba6a0d44a605a69e00c6bb2fd1ff3971 100644 (file)
@@ -560,8 +560,7 @@ testQemuMonitorJSONGetTPMModels(const void *opaque)
 {
     const testGenericData *data = opaque;
     virDomainXMLOption *xmlopt = data->xmlopt;
-    int ret = -1;
-    char **tpmmodels = NULL;
+    g_auto(GStrv) tpmmodels = NULL;
     int ntpmmodels = 0;
     g_autoptr(qemuMonitorTest) test = NULL;
 
@@ -574,16 +573,16 @@ testQemuMonitorJSONGetTPMModels(const void *opaque)
                                "  \"passthrough\""
                                "  ]"
                                "}") < 0)
-        goto cleanup;
+        return -1;
 
     if ((ntpmmodels = qemuMonitorGetTPMModels(qemuMonitorTestGetMonitor(test),
                                               &tpmmodels)) < 0)
-        goto cleanup;
+        return -1;
 
     if (ntpmmodels != 1) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "ntpmmodels %d is not 1", ntpmmodels);
-        goto cleanup;
+        return -1;
     }
 
 #define CHECK(i, wantname) \
@@ -592,7 +591,7 @@ testQemuMonitorJSONGetTPMModels(const void *opaque)
             virReportError(VIR_ERR_INTERNAL_ERROR, \
                            "name %s is not %s", \
                            tpmmodels[i], (wantname)); \
-            goto cleanup; \
+            return -1; \
         } \
     } while (0)
 
@@ -600,11 +599,7 @@ testQemuMonitorJSONGetTPMModels(const void *opaque)
 
 #undef CHECK
 
-    ret = 0;
-
- cleanup:
-    g_strfreev(tpmmodels);
-    return ret;
+    return 0;
 }