[libvirt PATCH 5/7] virshtest: refactor testCompareOutputLit

Ján Tomko jtomko at redhat.com
Sun Feb 9 01:32:35 UTC 2020


Use g_autofree and get rid of the cleanup label.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 tests/virshtest.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/tests/virshtest.c b/tests/virshtest.c
index 189238b826..83675710ea 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -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", \
-- 
2.21.1




More information about the libvir-list mailing list