From nobody Sun Feb 8 19:24:22 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=1630789645; cv=none; d=zohomail.com; s=zohoarc; b=PHqbbo2D3d+t/HrAEI9fsBwJC9RMfD0NoB+h4EBwU2+HZt0giUmRTXIsvVbGkTXQRKJKaAp/kRoE4eXLJ2oycAysyTRKjJY8CvF7RjuFncDNrHT6NfcuPrOfqBTVBwD7MGgDUD8GEC0IQ3tMiCtjtgpoxeHfad4j6XUbTmSTigw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630789645; 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=P+91bzSZDIXNug1GRWS6EG/K2bTDx3RhAlDNkRgs9mM=; b=JNN1YmbpBCF4rWKxPV2IPJGnnXP8AbopNJFs838WpwnkVf1kPk3Ho/2OZ8Q5KJQgnZFqJF0K2FEgGQdSkOB0bmxvFT3uOHMfrllp/9iPLagfZxpQtNEw1OFJhQ9ujhdFfySgQS1FF6WmTbnmM3yGHzWdJxyBcpFRwCEXZbExBe4= 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 1630789645276408.86994563303097; Sat, 4 Sep 2021 14:07:25 -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-119-DZVeg7XbPAiGExjOuESgsQ-1; Sat, 04 Sep 2021 17:07:22 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E7AD10060F8; Sat, 4 Sep 2021 21:07:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 389AC1F4; Sat, 4 Sep 2021 21:07:17 +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 E989244A5C; Sat, 4 Sep 2021 21:07:16 +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 184KiXAm008767 for ; Sat, 4 Sep 2021 16:44:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D56D2619D; Sat, 4 Sep 2021 20:44:33 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB79B1F4 for ; Sat, 4 Sep 2021 20:44:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630789644; 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=P+91bzSZDIXNug1GRWS6EG/K2bTDx3RhAlDNkRgs9mM=; b=DZ2btrvSmq4YAyRmIpXFyhkNm7PMPGuAn3qTA0kslZOxUo2T65MjoHNfIcXIH4M3T2VH+Z 1FWN0sOf99uupG8VB/b5uC/WqcfAJ8swmxzSW2et1f91aGkTEajQWaThOEGsSPWSWUltxY +gOVcSnKdX2JyjZC6sDaIDpflaOCSPc= X-MC-Unique: DZVeg7XbPAiGExjOuESgsQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 07/24] tests: libxl: use g_autofree Date: Sat, 4 Sep 2021 22:44:05 +0200 Message-Id: <9e806c377da7aab0d42b967842390f3ab0db7bfd.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.84 on 10.5.11.23 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: 1630789645890100001 Signed-off-by: J=C3=A1n Tomko --- tests/libxlxml2domconfigtest.c | 15 +++++---------- tests/xlconfigtest.c | 25 ++++++++----------------- tests/xmconfigtest.c | 16 +++++----------- 3 files changed, 18 insertions(+), 38 deletions(-) diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index 19385c6fb5..2bc5c26223 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -53,9 +53,9 @@ testCompareXMLToDomConfig(const char *xmlfile, xentoollog_logger *log =3D NULL; virPortAllocatorRange *gports =3D NULL; virDomainDef *vmdef =3D NULL; - char *actualjson =3D NULL; - char *tempjson =3D NULL; - char *expectjson =3D NULL; + g_autofree char *actualjson =3D NULL; + g_autofree char *tempjson =3D NULL; + g_autofree char *expectjson =3D NULL; g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 libxl_domain_config_init(&actualconfig); @@ -128,9 +128,6 @@ testCompareXMLToDomConfig(const char *xmlfile, vmdef->graphics[0]->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC) virPortAllocatorRelease(vmdef->graphics[0]->data.vnc.port); =20 - VIR_FREE(expectjson); - VIR_FREE(actualjson); - VIR_FREE(tempjson); virDomainDefFree(vmdef); virPortAllocatorRangeFree(gports); libxl_domain_config_dispose(&actualconfig); @@ -150,16 +147,14 @@ testCompareXMLToDomConfigHelper(const void *data) { int ret =3D -1; const struct testInfo *info =3D data; - char *xmlfile =3D NULL; - char *jsonfile =3D NULL; + g_autofree char *xmlfile =3D NULL; + g_autofree char *jsonfile =3D NULL; =20 xmlfile =3D g_strdup_printf("%s/libxlxml2domconfigdata/%s.xml", abs_sr= cdir, info->name); jsonfile =3D g_strdup_printf("%s/libxlxml2domconfigdata/%s.json", abs_= srcdir, info->name); =20 ret =3D testCompareXMLToDomConfig(xmlfile, jsonfile); =20 - VIR_FREE(xmlfile); - VIR_FREE(jsonfile); return ret; } =20 diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index 0a2997b8b6..95ee670b00 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -45,7 +45,7 @@ static libxlDriverPrivate *driver; static char * testReplaceVarsXML(const char *xml) { - char *xmlcfgData; + g_autofree char *xmlcfgData =3D NULL; char *replacedXML; =20 if (virTestLoadFile(xml, &xmlcfgData) < 0) @@ -54,7 +54,6 @@ testReplaceVarsXML(const char *xml) replacedXML =3D virStringReplace(xmlcfgData, "/LIBXL_FIRMWARE_DIR", LIBXL_FIRMWARE_DIR); =20 - VIR_FREE(xmlcfgData); return replacedXML; } =20 @@ -65,13 +64,13 @@ testReplaceVarsXML(const char *xml) static int testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars) { - char *gotxlcfgData =3D NULL; + g_autofree char *gotxlcfgData =3D NULL; g_autoptr(virConf) conf =3D NULL; g_autoptr(virConnect) conn =3D NULL; int wrote =3D 4096; int ret =3D -1; virDomainDef *def =3D NULL; - char *replacedXML =3D NULL; + g_autofree char *replacedXML =3D NULL; =20 gotxlcfgData =3D g_new0(char, wrote); =20 @@ -108,8 +107,6 @@ testCompareParseXML(const char *xlcfg, const char *xml,= bool replaceVars) ret =3D 0; =20 fail: - VIR_FREE(replacedXML); - VIR_FREE(gotxlcfgData); virDomainDefFree(def); =20 return ret; @@ -122,13 +119,13 @@ testCompareParseXML(const char *xlcfg, const char *xm= l, bool replaceVars) static int testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars) { - char *xlcfgData =3D NULL; - char *gotxml =3D NULL; + g_autofree char *xlcfgData =3D NULL; + g_autofree char *gotxml =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; g_autoptr(virConnect) conn =3D NULL; virDomainDef *def =3D NULL; - char *replacedXML =3D NULL; + g_autofree char *replacedXML =3D NULL; g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 conn =3D virGetConnect(); @@ -161,9 +158,6 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) ret =3D 0; =20 fail: - VIR_FREE(replacedXML); - VIR_FREE(xlcfgData); - VIR_FREE(gotxml); virDomainDefFree(def); =20 return ret; @@ -181,8 +175,8 @@ testCompareHelper(const void *data) { int result =3D -1; const struct testInfo *info =3D data; - char *xml =3D NULL; - char *cfg =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *cfg =3D NULL; =20 xml =3D g_strdup_printf("%s/xlconfigdata/test-%s.xml", abs_srcdir, inf= o->name); cfg =3D g_strdup_printf("%s/xlconfigdata/test-%s.cfg", abs_srcdir, inf= o->name); @@ -192,9 +186,6 @@ testCompareHelper(const void *data) else result =3D testCompareFormatXML(cfg, xml, info->replaceVars); =20 - VIR_FREE(xml); - VIR_FREE(cfg); - return result; } =20 diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 9d5eb85bf9..a756f752f8 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -39,7 +39,7 @@ static libxlDriverPrivate *driver; static int testCompareParseXML(const char *xmcfg, const char *xml) { - char *gotxmcfgData =3D NULL; + g_autofree char *gotxmcfgData =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; g_autoptr(virConnect) conn =3D NULL; @@ -73,7 +73,6 @@ testCompareParseXML(const char *xmcfg, const char *xml) ret =3D 0; =20 fail: - VIR_FREE(gotxmcfgData); virDomainDefFree(def); =20 return ret; @@ -82,8 +81,8 @@ testCompareParseXML(const char *xmcfg, const char *xml) static int testCompareFormatXML(const char *xmcfg, const char *xml) { - char *xmcfgData =3D NULL; - char *gotxml =3D NULL; + g_autofree char *xmcfgData =3D NULL; + g_autofree char *gotxml =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; virDomainDef *def =3D NULL; @@ -107,8 +106,6 @@ testCompareFormatXML(const char *xmcfg, const char *xml) ret =3D 0; =20 fail: - VIR_FREE(xmcfgData); - VIR_FREE(gotxml); virDomainDefFree(def); =20 return ret; @@ -125,8 +122,8 @@ testCompareHelper(const void *data) { int result =3D -1; const struct testInfo *info =3D data; - char *xml =3D NULL; - char *cfg =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *cfg =3D NULL; =20 xml =3D g_strdup_printf("%s/xmconfigdata/test-%s.xml", abs_srcdir, inf= o->name); cfg =3D g_strdup_printf("%s/xmconfigdata/test-%s.cfg", abs_srcdir, inf= o->name); @@ -136,9 +133,6 @@ testCompareHelper(const void *data) else result =3D testCompareFormatXML(cfg, xml); =20 - VIR_FREE(xml); - VIR_FREE(cfg); - return result; } =20 --=20 2.31.1