[libvirt] [PATCH] tests: use VIR_AUTOUNREF in storagepoolcapstest

Pavel Hrdina posted 1 patch 5 years, 1 month ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/8c0fe9c64980235c6ce4eff32f8c54f3f851fb44.1551957174.git.phrdina@redhat.com
tests/storagepoolcapstest.c | 31 +++++++++++--------------------
1 file changed, 11 insertions(+), 20 deletions(-)
[libvirt] [PATCH] tests: use VIR_AUTOUNREF in storagepoolcapstest
Posted by Pavel Hrdina 5 years, 1 month ago
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 tests/storagepoolcapstest.c | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/tests/storagepoolcapstest.c b/tests/storagepoolcapstest.c
index f8b560c2f0..518a5fdfe7 100644
--- a/tests/storagepoolcapstest.c
+++ b/tests/storagepoolcapstest.c
@@ -54,30 +54,26 @@ test_virStoragePoolCapsFormat(const void *opaque)
     struct test_virStoragePoolCapsFormatData *data =
         (struct test_virStoragePoolCapsFormatData *) opaque;
     virCapsPtr driverCaps = data->driverCaps;
-    virStoragePoolCapsPtr poolCaps = NULL;
-    int ret = -1;
+    VIR_AUTOUNREF(virStoragePoolCapsPtr) poolCaps = NULL;
     VIR_AUTOFREE(char *) path = NULL;
     VIR_AUTOFREE(char *) poolCapsXML = NULL;
 
 
     if (!(poolCaps = virStoragePoolCapsNew(driverCaps)))
-        goto cleanup;
+        return -1;
 
     if (virAsprintf(&path, "%s/storagepoolcapsschemadata/poolcaps-%s.xml",
-                    abs_srcdir, data->filename) < 0)
-        goto cleanup;
+                    abs_srcdir, data->filename) < 0) {
+        return -1;
+    }
 
     if (!(poolCapsXML = virStoragePoolCapsFormat(poolCaps)))
-        goto cleanup;
+        return -1;
 
     if (virTestCompareToFile(poolCapsXML, path) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    virObjectUnref(poolCaps);
-    return ret;
+    return 0;
 }
 
 
@@ -85,8 +81,8 @@ static int
 mymain(void)
 {
     int ret = 0;
-    virCapsPtr fullCaps = NULL;
-    virCapsPtr fsCaps = NULL;
+    VIR_AUTOUNREF(virCapsPtr) fullCaps = NULL;
+    VIR_AUTOUNREF(virCapsPtr) fsCaps = NULL;
 
 #define DO_TEST(Filename, DriverCaps) \
     do { \
@@ -98,8 +94,7 @@ mymain(void)
 
     if (!(fullCaps = virCapabilitiesNew(VIR_ARCH_NONE, false, false)) ||
         !(fsCaps = virCapabilitiesNew(VIR_ARCH_NONE, false, false))) {
-        ret = -1;
-        goto cleanup;
+        return -1;
     }
 
     test_virCapabilitiesAddFullStoragePool(fullCaps);
@@ -108,10 +103,6 @@ mymain(void)
     DO_TEST("full", fullCaps);
     DO_TEST("fs", fsCaps);
 
- cleanup:
-    virObjectUnref(fullCaps);
-    virObjectUnref(fsCaps);
-
     return ret;
 }
 
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: use VIR_AUTOUNREF in storagepoolcapstest
Posted by Peter Krempa 5 years, 1 month ago
On Thu, Mar 07, 2019 at 12:13:00 +0100, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  tests/storagepoolcapstest.c | 31 +++++++++++--------------------
>  1 file changed, 11 insertions(+), 20 deletions(-)

ACK
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list