]> xenbits.xensource.com Git - libvirt.git/commitdiff
virshtest: refactor testCompareOutputLit
authorJán Tomko <jtomko@redhat.com>
Sun, 9 Feb 2020 01:07:19 +0000 (02:07 +0100)
committerJán Tomko <jtomko@redhat.com>
Tue, 11 Feb 2020 15:30:18 +0000 (16:30 +0100)
Use g_autofree and get rid of the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
tests/virshtest.c

index 189238b826259b50632509ae4adbee1e865da2e9..83675710ea17f3dbcda8c6cd838f4052f6d1b774 100644 (file)
@@ -60,26 +60,20 @@ static int
 testCompareOutputLit(const char *expectData,
                      const char *filter, const char *const argv[])
 {
-    int result = -1;
-    char *actualData = NULL;
+    g_autofree char *actualData = NULL;
 
     if (virTestCaptureProgramOutput(argv, &actualData, 4096) < 0)
-        goto cleanup;
+        return -1;
 
     if (filter && testFilterLine(actualData, filter) < 0)
-        goto cleanup;
+        return -1;
 
     if (STRNEQ(expectData, actualData)) {
         virTestDifference(stderr, expectData, actualData);
-        goto cleanup;
+        return -1;
     }
 
-    result = 0;
-
- cleanup:
-    VIR_FREE(actualData);
-
-    return result;
+    return 0;
 }
 
 # define VIRSH_DEFAULT abs_top_builddir "/tools/virsh", \