[libvirt PATCH 3/4] tests: bhyve: use g_autoptr where possible

Ján Tomko jtomko at redhat.com
Tue Jul 28 23:44:26 UTC 2020


Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 tests/bhyveargv2xmltest.c |  3 +--
 tests/bhyvexml2argvtest.c | 12 ++++--------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c
index e58a36d17c..e7ec3ae020 100644
--- a/tests/bhyveargv2xmltest.c
+++ b/tests/bhyveargv2xmltest.c
@@ -32,7 +32,7 @@ testCompareXMLToArgvFiles(const char *xmlfile,
     g_autofree char *cmd = NULL;
     g_autofree char *log = NULL;
     int ret = -1;
-    virDomainDefPtr vmdef = NULL;
+    g_autoptr(virDomainDef) vmdef = NULL;
 
     if (virTestLoadFile(cmdfile, &cmd) < 0)
         goto fail;
@@ -86,7 +86,6 @@ testCompareXMLToArgvFiles(const char *xmlfile,
     ret = 0;
 
  fail:
-    virDomainDefFree(vmdef);
     return ret;
 }
 
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index ce2af08d4c..33e7ac5772 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -29,10 +29,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
     g_autofree char *actualargv = NULL;
     g_autofree char *actualld = NULL;
     g_autofree char *actualdm = NULL;
-    virDomainDefPtr vmdef = NULL;
-    virCommandPtr cmd = NULL;
-    virCommandPtr ldcmd = NULL;
-    virConnectPtr conn;
+    g_autoptr(virDomainDef) vmdef = NULL;
+    g_autoptr(virCommand) cmd = NULL;
+    g_autoptr(virCommand) ldcmd = NULL;
+    g_autoptr(virConnect) conn = NULL;
     int ret = -1;
 
     if (!(conn = virGetConnect()))
@@ -99,10 +99,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
         vmdef->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC)
         virPortAllocatorRelease(vmdef->graphics[0]->data.vnc.port);
 
-    virCommandFree(cmd);
-    virCommandFree(ldcmd);
-    virDomainDefFree(vmdef);
-    virObjectUnref(conn);
     return ret;
 }
 
-- 
2.26.2




More information about the libvir-list mailing list