From aeb5951aa458725a5461e35775ac9cdb9d6ffe0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 28 Jul 2020 02:59:58 +0200 Subject: [PATCH] tests: bhyve: use g_autoptr where possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ján Tomko Reviewed-by: Laine Stump Reviewed-by: Roman Bogorodskiy --- 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; }