From nobody Sat May 18 07:31:12 2024 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=fail(p=quarantine dis=quarantine) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1673350576; cv=none; d=zohomail.com; s=zohoarc; b=PYGJb8GIQqK8XXn/c2aiO0Iu5xsLwMJNuxviE+5i1gV9h8/H8zmsL4UKRhuFF+8uW/bgb+8+S82U7kZABTcGWwj9nAPVQ8lTDLhUUzKTBqzrglaaaqQCjbCCs3fSn+Lu6KjoULy1X0aUTkQh3LDjgHMY8JBFDOB/vV7iXD/n0CA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673350576; h=Content-Type:Content-Transfer-Encoding:Cc: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=44ErjFSpxa+IC4Qx8+ZYac1AB2v9Jqi8vuSe6GA+z3k=; b=D6ERsLNu63Vg1BLuvzDgXt5taJh63ZlAJY350BtYWdGhuiow5hiIvlURkdIj2v6/WUT0376Wkt54b8rGI7Q9uRM/q6SeN2/zfp1kAURI/iG2V1otwKTVR+0KAFFN9qXKBQZky/N4EFeva4kHCQF0gXC8r0Ynl6QieAwl0SoQcrg= 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=fail header.from= (p=quarantine dis=quarantine) 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 1673350576515703.8395575656496; Tue, 10 Jan 2023 03:36:16 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-5oT9PQEbOQeIlK3YXtOE1w-1; Tue, 10 Jan 2023 06:36:10 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C164285C6E3; Tue, 10 Jan 2023 11:36:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB8E11121314; Tue, 10 Jan 2023 11:36:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4F54B194E016; Tue, 10 Jan 2023 11:36:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 27E8F194E102 for ; Tue, 10 Jan 2023 11:36:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1C17B4078906; Tue, 10 Jan 2023 11:36:06 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 145D94078903 for ; Tue, 10 Jan 2023 11:36:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F24ED85C6E0 for ; Tue, 10 Jan 2023 11:36:05 +0000 (UTC) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-460-FmiXWAzuPCq5B3OcePebSA-1; Tue, 10 Jan 2023 06:36:03 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NrpYg1YPgzJqBC for ; Tue, 10 Jan 2023 19:31:51 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 10 Jan 2023 19:35:57 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673350575; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=44ErjFSpxa+IC4Qx8+ZYac1AB2v9Jqi8vuSe6GA+z3k=; b=h6KvwVb4yVNOmZ8Xmmt97rOrxfICtDcOpZ0kn1KtThG40I+B2LdKdQPtpDVM5wI9t6nuFr I7T1AojxlnKlJv833QmPxex2sN6o3dQ4xd8riexerTQW7mxuJfhivYtRz6AV0+O8b62Y+w L2lDUjYepxc3Wa6KbBM4n2OSPBe2pPc= X-MC-Unique: 5oT9PQEbOQeIlK3YXtOE1w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: FmiXWAzuPCq5B3OcePebSA-1 From: Jiang Jiacheng To: Subject: [PATCH 1/2] conf: define g_autoptr for virNWFilterDef and virNWFilterRuleDef Date: Tue, 10 Jan 2023 19:29:25 +0800 Message-ID: <20230110112926.1235647-2-jiangjiacheng@huawei.com> In-Reply-To: <20230110112926.1235647-1-jiangjiacheng@huawei.com> References: <20230110112926.1235647-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yubihong@huawei.com, zhengchuan@huawei.com, linyilu@huawei.com, jiangjiacheng@huawei.com, xiexiangyou@huawei.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673350577596100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiang Jiacheng Reviewed-by: J=C3=A1n Tomko --- src/conf/nwfilter_conf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 1a38e4198c..7c09b3bcb9 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -522,9 +522,11 @@ struct _virNWFilterDef { =20 void virNWFilterRuleDefFree(virNWFilterRuleDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNWFilterRuleDef, virNWFilterRuleDefFree); =20 void virNWFilterDefFree(virNWFilterDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNWFilterDef, virNWFilterDefFree); =20 int virNWFilterTriggerRebuild(void); --=20 2.33.0 From nobody Sat May 18 07:31:12 2024 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=fail(p=quarantine dis=quarantine) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1673350583; cv=none; d=zohomail.com; s=zohoarc; b=WzNuLI/S23SjT85bsK3jioEk6PAuah/0Yy4wV9qldcD4g+BSfYMftbKV9YQD/KQFDWX2zQIa/nUmD6SymkLDIzgrUgZ0KiME5jhqfmGSYxSXQv8iYaTqE47IlB0SQb2ucydLQru3V9la+ualsxP3yFoD0F/0E7NvfVVyGZufvqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673350583; h=Content-Type:Content-Transfer-Encoding:Cc: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=bRxEUUl3xOgJdMr9SzCvTS4ln0JEOwLwvfjikBwa/Gk=; b=n5DW1Y0DhKBmq4BksroRaeWt3HIih3wC6P+RCLLlf8/8jnew1B6df0A0ed3RMRKkw9J1r7+G04msnOUE+uWd/fmeuWxOl4xbHbpK7Laat8A6FFeeqNM4JM/50sJ75g3ykfIbwv02sKSx0eOpHB04dYgTxAWmvNXO+U9lKe8YqMU= 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=fail header.from= (p=quarantine dis=quarantine) 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 1673350583242553.2456072072714; Tue, 10 Jan 2023 03:36:23 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-374-ez9X2UzwOe-js1VNXhBD_Q-1; Tue, 10 Jan 2023 06:36:11 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C09B8C5E14; Tue, 10 Jan 2023 11:36:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D3B7C16039; Tue, 10 Jan 2023 11:36:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8EAE1194E119; Tue, 10 Jan 2023 11:36:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E3B9A194E118 for ; Tue, 10 Jan 2023 11:36:07 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D749C1121319; Tue, 10 Jan 2023 11:36:07 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CFB4F1121314 for ; Tue, 10 Jan 2023 11:36:07 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B114D8C5E03 for ; Tue, 10 Jan 2023 11:36:07 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-84-eXRvTJlBPB6GN0v2cNboOw-1; Tue, 10 Jan 2023 06:36:04 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Nrpcb5tvPznVC7 for ; Tue, 10 Jan 2023 19:34:23 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 10 Jan 2023 19:35:57 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673350582; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=bRxEUUl3xOgJdMr9SzCvTS4ln0JEOwLwvfjikBwa/Gk=; b=ND/fDG7sRzcsyOXVMfEpzPXYl1PxOXDJHjlQxRM0AJSkm5VaVewlVvgR0qiHH8kYTwaOIF n3VyBFsx8zicQMFOKxMBrLst7+8co8uevbh24SuLOvQMvVKMlB36Mukt70Xroucemx7C+F GUc8sGW7oOslue3t76ElvBApGJHEj9Y= X-MC-Unique: ez9X2UzwOe-js1VNXhBD_Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: eXRvTJlBPB6GN0v2cNboOw-1 From: Jiang Jiacheng To: Subject: [PATCH V2 2/2] src/tests: use g_autoptr for virNWFilterDef and virNWFilterRuleDef Date: Tue, 10 Jan 2023 19:29:26 +0800 Message-ID: <20230110112926.1235647-3-jiangjiacheng@huawei.com> In-Reply-To: <20230110112926.1235647-1-jiangjiacheng@huawei.com> References: <20230110112926.1235647-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yubihong@huawei.com, zhengchuan@huawei.com, linyilu@huawei.com, jiangjiacheng@huawei.com, xiexiangyou@huawei.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673350583654100001 Content-Type: text/plain; charset="utf-8" Use g_autoptr() for virNWFilterDef and virNWFilterRuleDef and remove unnecessary label. Signed-off-by: Jiang Jiacheng Reviewed-by: J=C3=A1n Tomko --- src/conf/nwfilter_conf.c | 44 +++++++++++++++---------------------- tests/nwfilterxml2xmltest.c | 22 +++++++------------ 2 files changed, 26 insertions(+), 40 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index f41d3858da..8d198a7bb1 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2384,7 +2384,7 @@ virNWFilterRuleParse(xmlNodePtr node) int priority; =20 xmlNodePtr cur; - virNWFilterRuleDef *ret; + g_autoptr(virNWFilterRuleDef) ret =3D NULL; =20 ret =3D g_new0(virNWFilterRuleDef, 1); =20 @@ -2397,28 +2397,28 @@ virNWFilterRuleParse(xmlNodePtr node) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("rule node requires action attribute")); - goto err_exit; + return NULL; } =20 if ((ret->action =3D virNWFilterRuleActionTypeFromString(action)) < 0)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unknown rule action attribute value")); - goto err_exit; + return NULL; } =20 if (!direction) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("rule node requires direction attribute")); - goto err_exit; + return NULL; } =20 if ((ret->tt =3D virNWFilterRuleDirectionTypeFromString(direction)) < = 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unknown rule direction attribute value")); - goto err_exit; + return NULL; } =20 ret->priority =3D MAX_RULE_PRIORITY / 2; @@ -2455,10 +2455,10 @@ virNWFilterRuleParse(xmlNodePtr node) if (virNWFilterRuleDetailsParse(cur, ret, virAttr[i].att) < 0) { - goto err_exit; + return NULL; } if (virNWFilterRuleValidate(ret) < 0) - goto err_exit; + return NULL; break; } if (!found) { @@ -2476,11 +2476,7 @@ virNWFilterRuleParse(xmlNodePtr node) =20 virNWFilterRuleDefFixup(ret); =20 - return ret; - - err_exit: - g_clear_pointer(&ret, virNWFilterRuleDefFree); - return NULL; + return g_steal_pointer(&ret); } =20 =20 @@ -2561,7 +2557,7 @@ virNWFilterIsAllowedChain(const char *chainname) static virNWFilterDef * virNWFilterDefParseXML(xmlXPathContextPtr ctxt) { - virNWFilterDef *ret; + g_autoptr(virNWFilterDef) ret =3D NULL; xmlNodePtr curr =3D ctxt->node; g_autofree char *uuid =3D NULL; g_autofree char *chain =3D NULL; @@ -2576,7 +2572,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) if (!ret->name) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("filter has no name")); - goto cleanup; + return NULL; } =20 chain_pri_s =3D virXPathString("string(./@priority)", ctxt); @@ -2585,7 +2581,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) virReportError(VIR_ERR_INVALID_ARG, _("Could not parse chain priority '%s'"), chain_pri_s); - goto cleanup; + return NULL; } if (chain_priority < NWFILTER_MIN_FILTER_PRIORITY || chain_priority > NWFILTER_MAX_FILTER_PRIORITY) { @@ -2595,7 +2591,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) chain_priority, NWFILTER_MIN_FILTER_PRIORITY, NWFILTER_MAX_FILTER_PRIORITY); - goto cleanup; + return NULL; } } =20 @@ -2603,7 +2599,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) if (chain) { name_prefix =3D virNWFilterIsAllowedChain(chain); if (name_prefix =3D=3D NULL) - goto cleanup; + return NULL; ret->chainsuffix =3D g_steal_pointer(&chain); =20 if (chain_pri_s) { @@ -2626,13 +2622,13 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) if (virUUIDGenerate(ret->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("unable to generate uuid")); - goto cleanup; + return NULL; } } else { if (virUUIDParse(uuid, ret->uuid) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("malformed uuid element")); - goto cleanup; + return NULL; } } =20 @@ -2645,12 +2641,12 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) if (virXMLNodeNameEqual(curr, "rule")) { if (!(entry->rule =3D virNWFilterRuleParse(curr))) { virNWFilterEntryFree(entry); - goto cleanup; + return NULL; } } else if (virXMLNodeNameEqual(curr, "filterref")) { if (!(entry->include =3D virNWFilterIncludeParse(curr))) { virNWFilterEntryFree(entry); - goto cleanup; + return NULL; } } =20 @@ -2663,11 +2659,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) curr =3D curr->next; } =20 - return ret; - - cleanup: - virNWFilterDefFree(ret); - return NULL; + return g_steal_pointer(&ret); } =20 =20 diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c index ca037ad9a0..5c84c2fee9 100644 --- a/tests/nwfilterxml2xmltest.c +++ b/tests/nwfilterxml2xmltest.c @@ -16,31 +16,25 @@ testCompareXMLToXMLFiles(const char *inxml, const char = *outxml, bool expect_error) { g_autofree char *actual =3D NULL; - int ret =3D -1; - virNWFilterDef *dev =3D NULL; + g_autoptr(virNWFilterDef) def =3D NULL; =20 virResetLastError(); =20 - if (!(dev =3D virNWFilterDefParse(NULL, inxml, 0))) { + if (!(def =3D virNWFilterDefParse(NULL, inxml, 0))) { if (expect_error) { virResetLastError(); - goto done; + return 0; } - goto fail; + return -1; } =20 - if (!(actual =3D virNWFilterDefFormat(dev))) - goto fail; + if (!(actual =3D virNWFilterDefFormat(def))) + return -1; =20 if (virTestCompareToFile(actual, outxml) < 0) - goto fail; + return -1; =20 - done: - ret =3D 0; - - fail: - virNWFilterDefFree(dev); - return ret; + return 0; } =20 typedef struct test_parms { --=20 2.33.0