From nobody Sun Feb 8 13:33:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630788681; cv=none; d=zohomail.com; s=zohoarc; b=I52xi9LGQpjgzwpfB3qs3lFG9xtN0so4hYdIEmNWWFFAyBtx5nxlcteCqqWDhcw3RoghhSnqi+FD2exSFsN9QNBtADRwUo+uqapkTXBAfjV8whmFWwL2EzkKMhmFFGRFzezAtuOVwEBYESZt0q7mymFGV84VEe0ShjJRXOYJWKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788681; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Aa+nO9dwJ4pE6DzCQF4SDs3TzgBl9L9zmaC5tQuW7nM=; b=Z0VH0vN+v1YMYDc1GNcnCmVFOtPaGrHWHkGtgeqfKus7/ZGvTuO/EkaOKNLT7hB25aBlS4NsYRpbvp31QnUHzz0uFe20BDUJTjcni7Jn0n9NPbrU9n4NRhsgT4bT1T6HPdT8D5v+gCWg5gFpqamrlyiqVZ+bG9tzfFPzrrVWJMQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630788681889349.2909352763694; Sat, 4 Sep 2021 13:51:21 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-593-tuIyovtuOO2B1b91_W-wUg-1; Sat, 04 Sep 2021 16:51:19 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44874824FAE; Sat, 4 Sep 2021 20:51:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A98177BF1; Sat, 4 Sep 2021 20:51:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E7DD31809C98; Sat, 4 Sep 2021 20:51:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 184KiV70008744 for ; Sat, 4 Sep 2021 16:44:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 088F32619D; Sat, 4 Sep 2021 20:44:31 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 865CE1F4 for ; Sat, 4 Sep 2021 20:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788680; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Aa+nO9dwJ4pE6DzCQF4SDs3TzgBl9L9zmaC5tQuW7nM=; b=T/tpmNiV12lj6F5xf18dO+9m5JLx7rsVKirt8fcvdAbiwHzrgepPohMNUXD4Q7ucayTE/c 6zTIqF/PRj67hURl52KsNakJzciLh9Ke9XR1q7hK4vypOArzWGwpvvBx/iFCphvF1m7y4L aunnOYdYhujwhEIo32ZU8rK5vRfMzDI= X-MC-Unique: tuIyovtuOO2B1b91_W-wUg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 04/24] tests: use g_autoptr instead of virObjectUnref Date: Sat, 4 Sep 2021 22:44:02 +0200 Message-Id: <88fe3b8a51bfaf8164f80de89b07eff8bd309af4.1630788206.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630788682796100001 Signed-off-by: J=C3=A1n Tomko --- tests/cputest.c | 9 +++------ tests/domaincapstest.c | 6 ++---- tests/networkxml2conftest.c | 3 +-- tests/networkxml2xmltest.c | 3 +-- tests/vircapstest.c | 6 ++---- tests/virmacmaptest.c | 6 ++---- tests/virpcitest.c | 18 ++++++------------ tests/virresctrltest.c | 6 ++---- tests/virscsitest.c | 3 +-- tests/virusbtest.c | 3 +-- tests/xlconfigtest.c | 6 ++---- tests/xmconfigtest.c | 3 +-- 12 files changed, 24 insertions(+), 48 deletions(-) diff --git a/tests/cputest.c b/tests/cputest.c index 3e99b9486b..11305d56c5 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -526,7 +526,7 @@ cpuTestCPUID(bool guest, const void *arg) g_autofree char *host =3D NULL; g_autoptr(virCPUDef) cpu =3D NULL; g_autofree char *result =3D NULL; - virDomainCapsCPUModels *models =3D NULL; + g_autoptr(virDomainCapsCPUModels) models =3D NULL; =20 hostFile =3D g_strdup_printf("%s/cputestdata/%s-cpuid-%s.xml", abs_src= dir, virArchToString(data->arch), data->host); @@ -563,7 +563,6 @@ cpuTestCPUID(bool guest, const void *arg) ret =3D cpuTestCompareXML(data->arch, cpu, result); =20 cleanup: - virObjectUnref(models); return ret; } =20 @@ -728,8 +727,8 @@ cpuTestUpdateLive(const void *arg) g_autoptr(virCPUData) disabledData =3D NULL; g_autofree char *expectedFile =3D NULL; g_autoptr(virCPUDef) expected =3D NULL; - virDomainCapsCPUModels *hvModels =3D NULL; - virDomainCapsCPUModels *models =3D NULL; + g_autoptr(virDomainCapsCPUModels) hvModels =3D NULL; + g_autoptr(virDomainCapsCPUModels) models =3D NULL; int ret =3D -1; =20 cpuFile =3D g_strdup_printf("cpuid-%s-guest", data->host); @@ -795,8 +794,6 @@ cpuTestUpdateLive(const void *arg) ret =3D cpuTestUpdateLiveCompare(data->arch, cpu, expected); =20 cleanup: - virObjectUnref(hvModels); - virObjectUnref(models); return ret; } =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index ca29644dee..6ab14a0179 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -75,7 +75,7 @@ fillQemuCaps(virDomainCaps *domCaps, { int ret =3D -1; char *path =3D NULL; - virQEMUCaps *qemuCaps =3D NULL; + g_autoptr(virQEMUCaps) qemuCaps =3D NULL; virDomainCapsLoader *loader =3D &domCaps->os.loader; virDomainVirtType virtType; =20 @@ -127,7 +127,6 @@ fillQemuCaps(virDomainCaps *domCaps, =20 ret =3D 0; cleanup: - virObjectUnref(qemuCaps); VIR_FREE(path); return ret; } @@ -208,7 +207,7 @@ static int test_virDomainCapsFormat(const void *opaque) { const struct testData *data =3D opaque; - virDomainCaps *domCaps =3D NULL; + g_autoptr(virDomainCaps) domCaps =3D NULL; char *path =3D NULL; char *domCapsXML =3D NULL; int ret =3D -1; @@ -256,7 +255,6 @@ test_virDomainCapsFormat(const void *opaque) cleanup: VIR_FREE(domCapsXML); VIR_FREE(path); - virObjectUnref(domCaps); return ret; } =20 diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 7444390b77..a2ecc6e80a 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -27,7 +27,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *= outconf, virCommand *cmd =3D NULL; char *pidfile =3D NULL; dnsmasqContext *dctx =3D NULL; - virNetworkXMLOption *xmlopt =3D NULL; + g_autoptr(virNetworkXMLOption) xmlopt =3D NULL; =20 if (!(xmlopt =3D networkDnsmasqCreateXMLConf())) goto fail; @@ -85,7 +85,6 @@ testCompareXMLToConfFiles(const char *inxml, const char *= outconf, VIR_FREE(hostsfileactual); VIR_FREE(pidfile); virCommandFree(cmd); - virObjectUnref(xmlopt); virNetworkObjEndAPI(&obj); dnsmasqContextFree(dctx); return ret; diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index 3b0a0b7c95..e1b5cdc748 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -30,7 +30,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *o= utxml, int ret; testCompareNetXML2XMLResult result =3D TEST_COMPARE_NET_XML2XML_RESULT= _SUCCESS; virNetworkDef *dev =3D NULL; - virNetworkXMLOption *xmlopt =3D NULL; + g_autoptr(virNetworkXMLOption) xmlopt =3D NULL; =20 if (!(xmlopt =3D networkDnsmasqCreateXMLConf())) goto cleanup; @@ -72,7 +72,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *o= utxml, =20 VIR_FREE(actual); virNetworkDefFree(dev); - virObjectUnref(xmlopt); return ret; } =20 diff --git a/tests/vircapstest.c b/tests/vircapstest.c index 7ec5b85222..ebabbbb9a0 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -151,7 +151,7 @@ static int test_virCapsDomainDataLookupQEMU(const void *data G_GNUC_UNUSED) { int ret =3D 0; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; =20 if (!(caps =3D testQemuCapsInit())) { ret =3D -1; @@ -196,7 +196,6 @@ test_virCapsDomainDataLookupQEMU(const void *data G_GNU= C_UNUSED) CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_VMWARE, NULL, "pc"); =20 out: - virObjectUnref(caps); return ret; } #endif /* WITH_QEMU */ @@ -206,7 +205,7 @@ static int test_virCapsDomainDataLookupLXC(const void *data G_GNUC_UNUSED) { int ret =3D 0; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; =20 if (!(caps =3D testLXCCapsInit())) { ret =3D -1; @@ -221,7 +220,6 @@ test_virCapsDomainDataLookupLXC(const void *data G_GNUC= _UNUSED) VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL); =20 out: - virObjectUnref(caps); return ret; } #endif /* WITH_LXC */ diff --git a/tests/virmacmaptest.c b/tests/virmacmaptest.c index 1b536af1ab..4e78615029 100644 --- a/tests/virmacmaptest.c +++ b/tests/virmacmaptest.c @@ -35,7 +35,7 @@ static int testMACLookup(const void *opaque) { const struct testData *data =3D opaque; - virMacMap *mgr =3D NULL; + g_autoptr(virMacMap) mgr =3D NULL; GSList *macs; GSList *next; size_t i, j; @@ -79,7 +79,6 @@ testMACLookup(const void *opaque) ret =3D 0; cleanup: VIR_FREE(file); - virObjectUnref(mgr); return ret; } =20 @@ -88,7 +87,7 @@ static int testMACRemove(const void *opaque) { const struct testData *data =3D opaque; - virMacMap *mgr =3D NULL; + g_autoptr(virMacMap) mgr =3D NULL; GSList *macs; size_t i; char *file =3D NULL; @@ -117,7 +116,6 @@ testMACRemove(const void *opaque) ret =3D 0; cleanup: VIR_FREE(file); - virObjectUnref(mgr); return ret; } =20 diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 0466e5a0f7..1cffe6e279 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -93,8 +93,8 @@ testVirPCIDeviceDetach(const void *opaque G_GNUC_UNUSED) int ret =3D -1; virPCIDevice *dev[] =3D {NULL, NULL, NULL}; size_t i, nDev =3D G_N_ELEMENTS(dev); - virPCIDeviceList *activeDevs =3D NULL; - virPCIDeviceList *inactiveDevs =3D NULL; + g_autoptr(virPCIDeviceList) activeDevs =3D NULL; + g_autoptr(virPCIDeviceList) inactiveDevs =3D NULL; int count; =20 if (!(activeDevs =3D virPCIDeviceListNew()) || @@ -126,8 +126,6 @@ testVirPCIDeviceDetach(const void *opaque G_GNUC_UNUSED) cleanup: for (i =3D 0; i < nDev; i++) virPCIDeviceFree(dev[i]); - virObjectUnref(activeDevs); - virObjectUnref(inactiveDevs); return ret; } =20 @@ -137,8 +135,8 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED) int ret =3D -1; virPCIDevice *dev[] =3D {NULL, NULL, NULL}; size_t i, nDev =3D G_N_ELEMENTS(dev); - virPCIDeviceList *activeDevs =3D NULL; - virPCIDeviceList *inactiveDevs =3D NULL; + g_autoptr(virPCIDeviceList) activeDevs =3D NULL; + g_autoptr(virPCIDeviceList) inactiveDevs =3D NULL; int count; =20 if (!(activeDevs =3D virPCIDeviceListNew()) || @@ -164,8 +162,6 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED) cleanup: for (i =3D 0; i < nDev; i++) virPCIDeviceFree(dev[i]); - virObjectUnref(activeDevs); - virObjectUnref(inactiveDevs); return ret; } =20 @@ -175,8 +171,8 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUS= ED) int ret =3D -1; virPCIDevice *dev[] =3D {NULL, NULL, NULL}; size_t i, nDev =3D G_N_ELEMENTS(dev); - virPCIDeviceList *activeDevs =3D NULL; - virPCIDeviceList *inactiveDevs =3D NULL; + g_autoptr(virPCIDeviceList) activeDevs =3D NULL; + g_autoptr(virPCIDeviceList) inactiveDevs =3D NULL; int count; =20 if (!(activeDevs =3D virPCIDeviceListNew()) || @@ -213,8 +209,6 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUS= ED) =20 ret =3D 0; cleanup: - virObjectUnref(activeDevs); - virObjectUnref(inactiveDevs); return ret; } =20 diff --git a/tests/virresctrltest.c b/tests/virresctrltest.c index 26fbde3668..b1dbf66d41 100644 --- a/tests/virresctrltest.c +++ b/tests/virresctrltest.c @@ -21,10 +21,10 @@ test_virResctrlGetUnused(const void *opaque) char *system_dir =3D NULL; char *resctrl_dir =3D NULL; int ret =3D -1; - virResctrlAlloc *alloc =3D NULL; + g_autoptr(virResctrlAlloc) alloc =3D NULL; char *schemata_str =3D NULL; char *schemata_file; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; =20 system_dir =3D g_strdup_printf("%s/vircaps2xmldata/linux-%s/system", a= bs_srcdir, data->filename); @@ -65,8 +65,6 @@ test_virResctrlGetUnused(const void *opaque) =20 ret =3D 0; cleanup: - virObjectUnref(caps); - virObjectUnref(alloc); VIR_FREE(system_dir); VIR_FREE(resctrl_dir); VIR_FREE(schemata_str); diff --git a/tests/virscsitest.c b/tests/virscsitest.c index 0d7c35a261..1b6a7b9ae9 100644 --- a/tests/virscsitest.c +++ b/tests/virscsitest.c @@ -60,7 +60,7 @@ test1(const void *data G_GNUC_UNUSED) static int test2(const void *data G_GNUC_UNUSED) { - virSCSIDeviceList *list =3D NULL; + g_autoptr(virSCSIDeviceList) list =3D NULL; virSCSIDevice *dev =3D NULL; virSCSIDevice *dev1 =3D NULL; bool free_dev =3D true; @@ -157,7 +157,6 @@ test2(const void *data G_GNUC_UNUSED) virSCSIDeviceFree(dev); if (free_dev1) virSCSIDeviceFree(dev1); - virObjectUnref(list); return ret; } =20 diff --git a/tests/virusbtest.c b/tests/virusbtest.c index baad7dd821..39a8f1a18e 100644 --- a/tests/virusbtest.c +++ b/tests/virusbtest.c @@ -70,7 +70,7 @@ static int testDeviceFind(const void *opaque) const struct findTestInfo *info =3D opaque; int ret =3D -1; virUSBDevice *dev =3D NULL; - virUSBDeviceList *devs =3D NULL; + g_autoptr(virUSBDeviceList) devs =3D NULL; int rv =3D 0; size_t i, ndevs =3D 0; =20 @@ -123,7 +123,6 @@ static int testDeviceFind(const void *opaque) ret =3D 0; =20 cleanup: - virObjectUnref(devs); virUSBDeviceFree(dev); return ret; } diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index e5c4a053bc..0a2997b8b6 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -67,7 +67,7 @@ testCompareParseXML(const char *xlcfg, const char *xml, b= ool replaceVars) { char *gotxlcfgData =3D NULL; g_autoptr(virConf) conf =3D NULL; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; int wrote =3D 4096; int ret =3D -1; virDomainDef *def =3D NULL; @@ -111,7 +111,6 @@ testCompareParseXML(const char *xlcfg, const char *xml,= bool replaceVars) VIR_FREE(replacedXML); VIR_FREE(gotxlcfgData); virDomainDefFree(def); - virObjectUnref(conn); =20 return ret; } @@ -127,7 +126,7 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) char *gotxml =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; - virConnectPtr conn; + g_autoptr(virConnect) conn =3D NULL; virDomainDef *def =3D NULL; char *replacedXML =3D NULL; g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); @@ -166,7 +165,6 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) VIR_FREE(xlcfgData); VIR_FREE(gotxml); virDomainDefFree(def); - virObjectUnref(conn); =20 return ret; } diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index bf74e4a163..9d5eb85bf9 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -42,7 +42,7 @@ testCompareParseXML(const char *xmcfg, const char *xml) char *gotxmcfgData =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; int wrote =3D 4096; virDomainDef *def =3D NULL; =20 @@ -75,7 +75,6 @@ testCompareParseXML(const char *xmcfg, const char *xml) fail: VIR_FREE(gotxmcfgData); virDomainDefFree(def); - virObjectUnref(conn); =20 return ret; } --=20 2.31.1