Ideally, turning pointers into g_auto* would be done in one step
and dropping cleanup label and unused @ret variable in second
step, but since this is a test we don't care that much, do we?
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/vircaps2xmltest.c | 31 +++++++++++--------------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c
index 5b1b60124a..1e6c113c77 100644
--- a/tests/vircaps2xmltest.c
+++ b/tests/vircaps2xmltest.c
@@ -38,12 +38,11 @@ test_virCapabilities(const void *opaque)
{
struct virCapabilitiesData *data = (struct virCapabilitiesData *) opaque;
const char *archStr = virArchToString(data->arch);
- virCaps *caps = NULL;
- char *capsXML = NULL;
- char *path = NULL;
- char *system = NULL;
- char *resctrl = NULL;
- int ret = -1;
+ g_autoptr(virCaps) caps = NULL;
+ g_autofree char *capsXML = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *system = NULL;
+ g_autofree char *resctrl = NULL;
system = g_strdup_printf("%s/vircaps2xmldata/linux-%s/system", abs_srcdir,
data->filename);
@@ -56,34 +55,26 @@ test_virCapabilities(const void *opaque)
caps = virCapabilitiesNew(data->arch, data->offlineMigrate,
data->liveMigrate);
if (!caps)
- goto cleanup;
+ return -1;
if (!(caps->host.numa = virCapabilitiesHostNUMANewHost()))
- goto cleanup;
+ return -1;
if (virCapabilitiesInitCaches(caps) < 0)
- goto cleanup;
+ return -1;
virFileWrapperClearPrefixes();
if (!(capsXML = virCapabilitiesFormatXML(caps)))
- goto cleanup;
+ return -1;
path = g_strdup_printf("%s/vircaps2xmldata/vircaps-%s-%s.xml", abs_srcdir,
archStr, data->filename);
if (virTestCompareToFile(capsXML, path) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
-
- cleanup:
- VIR_FREE(system);
- VIR_FREE(resctrl);
- VIR_FREE(path);
- VIR_FREE(capsXML);
- virObjectUnref(caps);
- return ret;
+ return 0;
}
static int
--
2.31.1