]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: vmx: use g_autofree
authorJán Tomko <jtomko@redhat.com>
Sat, 4 Sep 2021 20:37:06 +0000 (22:37 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 9 Sep 2021 16:06:13 +0000 (18:06 +0200)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
tests/vmx2xmltest.c
tests/xml2vmxtest.c

index 33bf24371743a4112e1141e97f0bf95ff3aa88ea..cd44a84a07a46628d473f67bd6f202940d06e51c 100644 (file)
@@ -69,8 +69,8 @@ static int
 testCompareFiles(const char *vmx, const char *xml, bool should_fail_parse)
 {
     int ret = -1;
-    char *vmxData = NULL;
-    char *formatted = NULL;
+    g_autofree char *vmxData = NULL;
+    g_autofree char *formatted = NULL;
     virDomainDef *def = NULL;
 
     if (virTestLoadFile(vmx, &vmxData) < 0)
@@ -102,8 +102,6 @@ testCompareFiles(const char *vmx, const char *xml, bool should_fail_parse)
     ret = 0;
 
  cleanup:
-    VIR_FREE(vmxData);
-    VIR_FREE(formatted);
     virDomainDefFree(def);
 
     return ret;
@@ -119,8 +117,8 @@ testCompareHelper(const void *data)
 {
     int ret = -1;
     const struct testInfo *info = data;
-    char *vmx = NULL;
-    char *xml = NULL;
+    g_autofree char *vmx = NULL;
+    g_autofree char *xml = NULL;
 
     vmx = g_strdup_printf("%s/vmx2xmldata/%s.vmx", abs_srcdir,
                           info->file);
@@ -129,9 +127,6 @@ testCompareHelper(const void *data)
 
     ret = testCompareFiles(vmx, xml, info->should_fail);
 
-    VIR_FREE(vmx);
-    VIR_FREE(xml);
-
     return ret;
 }
 
index fb87000529005c7f76abdd01b601137aef6f5480..cb70f70f4f2238d70f9349f125cd575fd206a0a3 100644 (file)
@@ -71,7 +71,7 @@ static int
 testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
 {
     int result = -1;
-    char *formatted = NULL;
+    g_autofree char *formatted = NULL;
     virDomainDef *def = NULL;
 
     def = virDomainDefParseFile(xml, xmlopt, NULL,
@@ -95,7 +95,6 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
     result = 0;
 
  failure:
-    VIR_FREE(formatted);
     virDomainDefFree(def);
 
     return result;
@@ -112,8 +111,8 @@ testCompareHelper(const void *data)
 {
     int result = -1;
     const struct testInfo *info = data;
-    char *xml = NULL;
-    char *vmx = NULL;
+    g_autofree char *xml = NULL;
+    g_autofree char *vmx = NULL;
 
     xml = g_strdup_printf("%s/xml2vmxdata/xml2vmx-%s.xml", abs_srcdir,
                           info->input);
@@ -122,9 +121,6 @@ testCompareHelper(const void *data)
 
     result = testCompareFiles(xml, vmx, info->virtualHW_version);
 
-    VIR_FREE(xml);
-    VIR_FREE(vmx);
-
     return result;
 }
 
@@ -141,7 +137,7 @@ static char *
 testFormatVMXFileName(const char *src, void *opaque G_GNUC_UNUSED)
 {
     bool success = false;
-    char *copyOfDatastorePath = NULL;
+    g_autofree char *copyOfDatastorePath = NULL;
     char *tmp = NULL;
     char *saveptr = NULL;
     char *datastoreName = NULL;
@@ -182,8 +178,6 @@ testFormatVMXFileName(const char *src, void *opaque G_GNUC_UNUSED)
     if (! success)
         VIR_FREE(absolutePath);
 
-    VIR_FREE(copyOfDatastorePath);
-
     return absolutePath;
 }