[libvirt PATCH 5/7] virshtest: refactor testCompareOutputLit

Ján Tomko posted 7 patches 6 years ago
[libvirt PATCH 5/7] virshtest: refactor testCompareOutputLit
Posted by Ján Tomko 6 years ago
Use g_autofree and get rid of the cleanup label.

Signed-off-by: Ján Tomko <jtomko@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

Re: [libvirt PATCH 5/7] virshtest: refactor testCompareOutputLit
Posted by Daniel P. Berrangé 5 years, 12 months ago
On Sun, Feb 09, 2020 at 02:32:35AM +0100, Ján Tomko wrote:
> Use g_autofree and get rid of the cleanup label.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  tests/virshtest.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|