1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

tests: use VIR_AUTOUNREF in storagepoolcapstest

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2019-03-07 12:12:11 +01:00
parent 9dadc73029
commit 8c0fe9c649

View File

@ -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;
}