]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virTestCompareToULL: Use VIR_AUTOFREE()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 20 Feb 2019 13:12:09 +0000 (14:12 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 20 Feb 2019 14:53:32 +0000 (15:53 +0100)
In order to save a few lines of code, and also since it's hype
let's use VIR_AUTOFREE() for the two strings we allocate there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/testutils.c

index d2219ad21e5dc544d8d2ce86c04feef6945bdade..ac8641865395d6c0fd95ecaa95d164eb4946b2f7 100644 (file)
@@ -822,23 +822,16 @@ int
 virTestCompareToULL(unsigned long long content,
                     unsigned long long src)
 {
-    char *strcontent = NULL;
-    char *strsrc = NULL;
-    int ret = -1;
+    VIR_AUTOFREE(char *) strcontent = NULL;
+    VIR_AUTOFREE(char *) strsrc = NULL;
 
     if (virAsprintf(&strcontent, "%llu", content) < 0)
-        goto cleanup;
+        return -1;
 
     if (virAsprintf(&strsrc, "%llu", src) < 0)
-        goto cleanup;
-
-    ret = virTestCompareToString(strcontent, strsrc);
-
- cleanup:
-    VIR_FREE(strcontent);
-    VIR_FREE(strsrc);
+        return -1;
 
-    return ret;
+    return virTestCompareToString(strcontent, strsrc);
 }
 
 /*