From nobody Sun Feb 8 19:25:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630788723; cv=none; d=zohomail.com; s=zohoarc; b=kvYKfzH73NwJ87rHvywXpwkV+SBDLaRdjIQOHwV2jAJeAKO2sQ9znwyDnLISzSoWscU8HbSWaaNpN/8lKry+BWGZhbVXsOSz47Fnb6QVNmDFpOg4UAx5cQ//gaBw0OmIUxf+BUXzQx9HJjq5o1oerWqWh/8Ye5k0QqbJftdhki4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788723; 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=HwBLco/FqTtKxe/IZrT4zEGdpV4GhptNgO5tK4O6FRY=; b=jflC7XhRppdOrG/xSOPCQbePsE3pugILuLS82/UhP7ltMzaqKnZSDjCPaFgOpBdVvwFqQmZEZTps8zObYPlhX891kyigZ6HBkvp5je4qMQQKkykhZ8dpGPb5LzhupZq5ENDLnylAJ2pC1JwfmRx/o5xcRS4bO4KER+c7bSrghfg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630788723480975.3876346895081; Sat, 4 Sep 2021 13:52:03 -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-164-xO8y1ug5MnqK6ywI7E2f_A-1; Sat, 04 Sep 2021 16:51:28 -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 A141A824FA6; Sat, 4 Sep 2021 20:51:23 +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 85B0A77BF1; Sat, 4 Sep 2021 20:51:23 +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 392DC1800B9C; Sat, 4 Sep 2021 20:51:23 +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 184KiYAF008780 for ; Sat, 4 Sep 2021 16:44:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3D6DB2619D; Sat, 4 Sep 2021 20:44:34 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAABE1F4 for ; Sat, 4 Sep 2021 20:44:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788722; 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=HwBLco/FqTtKxe/IZrT4zEGdpV4GhptNgO5tK4O6FRY=; b=KjGRI4A5ryOBulS/VHCuUGzZklMNcmdyVm4Hi/AVLsartQmlpK7SfGJdYxkQEXMDZtyohV 5Nna/XBFQt1znNjPYK2Bj5CPk6+7bhSkLEnHLN+HLbKY7SOjLjXuBPp2jR0skcvfV3+OcZ PPgMGXWp6CB5kSQzDCZIARsk5Nwgwq4= X-MC-Unique: xO8y1ug5MnqK6ywI7E2f_A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 08/24] tests: nwfilter: use g_autofree Date: Sat, 4 Sep 2021 22:44:06 +0200 Message-Id: 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: 1630788723901100001 Signed-off-by: J=C3=A1n Tomko --- tests/nwfilterebiptablestest.c | 21 +++++++-------------- tests/nwfilterxml2firewalltest.c | 12 ++++-------- tests/nwfilterxml2xmltest.c | 10 +++------- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c index 65b63959fb..7b32e90d19 100644 --- a/tests/nwfilterebiptablestest.c +++ b/tests/nwfilterebiptablestest.c @@ -101,7 +101,7 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_= GNUC_UNUSED) "ebtables --concurrent -t nat -X libvirt-I-vnet0\n" "ebtables --concurrent -t nat -F libvirt-O-vnet0\n" "ebtables --concurrent -t nat -X libvirt-O-vnet0\n"; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -119,7 +119,6 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_= GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -167,7 +166,7 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G= _GNUC_UNUSED) "ebtables --concurrent -t nat -L libvirt-P-vnet0\n" "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n" "ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n= "; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -185,7 +184,6 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G= _GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -211,7 +209,7 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaq= ue G_GNUC_UNUSED) "ebtables --concurrent -t nat -X libvirt-J-vnet0\n" "ebtables --concurrent -t nat -F libvirt-P-vnet0\n" "ebtables --concurrent -t nat -X libvirt-P-vnet0\n"; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -229,7 +227,6 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaq= ue G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -240,7 +237,7 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G= _GNUC_UNUSED) g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *expected =3D VIR_NWFILTER_NEW_RULES_TEARDOWN; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -258,7 +255,6 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G= _GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -306,7 +302,7 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaqu= e G_GNUC_UNUSED) "ebtables --concurrent -t nat -A libvirt-J-vnet0 -j DROP\n" "ebtables --concurrent -t nat -A PREROUTING -i vnet0 -j libvirt-J-= vnet0\n" "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n= "; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; virMacAddr mac =3D { .addr =3D { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 } = }; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); @@ -325,7 +321,6 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaqu= e G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -381,7 +376,7 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *op= aque G_GNUC_UNUSED) "ebtables --concurrent -t nat -A POSTROUTING -o vnet0 -j libvirt-P= -vnet0\n" "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n" "ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n= "; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; virMacAddr mac =3D { .addr =3D { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 } = }; const char *servers[] =3D { "192.168.122.1", "10.0.0.1", "10.0.0.2" }; @@ -410,7 +405,6 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *op= aque G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -460,7 +454,7 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opa= que G_GNUC_UNUSED) "ebtables --concurrent -t nat -A POSTROUTING -o vnet0 -j libvirt-P= -vnet0\n" "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n" "ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n= "; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -478,7 +472,6 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opa= que G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index 7fefd3ce75..3e8436a98c 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -229,7 +229,7 @@ virNWFilterIncludeDefToRuleInst(virNWFilterIncludeDef *= inc, { GHashTable *tmpvars =3D NULL; int ret =3D -1; - char *xml; + g_autofree char *xml =3D NULL; =20 xml =3D g_strdup_printf("%s/nwfilterxml2firewalldata/%s.xml", abs_srcd= ir, inc->filterref); @@ -249,7 +249,6 @@ virNWFilterIncludeDefToRuleInst(virNWFilterIncludeDef *= inc, if (ret < 0) virNWFilterInstReset(inst); virHashFree(tmpvars); - VIR_FREE(xml); return ret; } =20 @@ -350,7 +349,7 @@ static int testSetDefaultParameters(GHashTable *vars) static int testCompareXMLToArgvFiles(const char *xml, const char *cmdline) { - char *actualargv =3D NULL; + g_autofree char *actualargv =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; GHashTable *vars =3D virHashNew(virNWFilterVarValueHashFree); virNWFilterInst inst; @@ -382,7 +381,6 @@ static int testCompareXMLToArgvFiles(const char *xml, ret =3D 0; =20 cleanup: - VIR_FREE(actualargv); virNWFilterInstReset(&inst); virHashFree(vars); return ret; @@ -398,8 +396,8 @@ testCompareXMLToIPTablesHelper(const void *data) { int result =3D -1; const struct testInfo *info =3D data; - char *xml =3D NULL; - char *args =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *args =3D NULL; =20 xml =3D g_strdup_printf("%s/nwfilterxml2firewalldata/%s.xml", abs_srcdir, info->name); @@ -408,8 +406,6 @@ testCompareXMLToIPTablesHelper(const void *data) =20 result =3D testCompareXMLToArgvFiles(xml, args); =20 - VIR_FREE(xml); - VIR_FREE(args); return result; } =20 diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c index 82ce042e01..7a7e05965b 100644 --- a/tests/nwfilterxml2xmltest.c +++ b/tests/nwfilterxml2xmltest.c @@ -20,7 +20,7 @@ static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool expect_error) { - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; virNWFilterDef *dev =3D NULL; =20 @@ -44,7 +44,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *o= utxml, ret =3D 0; =20 fail: - VIR_FREE(actual); virNWFilterDefFree(dev); return ret; } @@ -59,17 +58,14 @@ testCompareXMLToXMLHelper(const void *data) { int result =3D -1; const test_parms *tp =3D data; - char *inxml =3D NULL; - char *outxml =3D NULL; + g_autofree char *inxml =3D NULL; + g_autofree char *outxml =3D NULL; =20 inxml =3D g_strdup_printf("%s/nwfilterxml2xmlin/%s.xml", abs_srcdir, t= p->name); outxml =3D g_strdup_printf("%s/nwfilterxml2xmlout/%s.xml", abs_srcdir,= tp->name); =20 result =3D testCompareXMLToXMLFiles(inxml, outxml, tp->expect_warning); =20 - VIR_FREE(inxml); - VIR_FREE(outxml); - return result; } =20 --=20 2.31.1