From nobody Sat May 18 12:12:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1673263624; cv=none; d=zohomail.com; s=zohoarc; b=IdxnAVttxwW8QqcrmofZsK9bPJbyvwDDqMW3vbyKFw4tH9rSPLFELnn7cIcZmMOzIuZWxHrFngT+wpobZ28A9OaAACzTP9w0eciq8xLuacPWdou6R+9CjXLdLB3Snrj59FOWJRod681wAqDzIyW6FbJ+dxXS7Kd1hNfq6Bdbm+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673263624; 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=P097h+ffGIdA9vYzta7RsRU3hgmzwwEeRkt31aNm6llvF9WlwmodvpfU4ae2TYSLxKjOGHP7gJUrT/vKuNsIiNedc65X6QoSSIPVdgfl+Y2zMLV7P6tQkyZQTwqOA/TnVQHdlk+TOuTlBEYDJNnZXseXlr2ShovCV+2ih83sw6U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1673263624508368.2756379934633; Mon, 9 Jan 2023 03:27:04 -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-611-GtC8k47-PmuUgDzKI_0Ceg-1; Mon, 09 Jan 2023 06:26:13 -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 8E46388B7B8; Mon, 9 Jan 2023 11:26:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7245E1121320; Mon, 9 Jan 2023 11:26:11 +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 05CDD1947B83; Mon, 9 Jan 2023 11:26:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A53351947B8C for ; Mon, 9 Jan 2023 11:26:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7B334140EBF6; Mon, 9 Jan 2023 11:26:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 732F0140EBF5 for ; Mon, 9 Jan 2023 11:26:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 53F4F101A521 for ; Mon, 9 Jan 2023 11:26:09 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-191-CGpziODGOJG2oVQ7Um2mwQ-1; Mon, 09 Jan 2023 06:26:04 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NrBRS1cYjzRr33; Mon, 9 Jan 2023 19:24:20 +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; Mon, 9 Jan 2023 19:25:59 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673263623; 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=gs5KGUvI/a3B8oIro6LfRgYzcAulDhw5QH+ITiDYmPXlnkKWsLJM4ADO2NP5i7WJUJxlL8 RLhtRZ7k/xevLDSoXL/vPy3DnfVQiytASZVeABhfwY3+bLRiq5TCddkCLpg8NHyHcnhuId 1Bc41dU7ndTbqdLrKrTlQVnT+pPK//E= X-MC-Unique: GtC8k47-PmuUgDzKI_0Ceg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: CGpziODGOJG2oVQ7Um2mwQ-1 From: Jiang Jiacheng To: , , , Subject: [PATCH 1/3] conf: define g_autoptr for virNWFilterDef and virNWFilterRuleDef Date: Mon, 9 Jan 2023 19:19:29 +0800 Message-ID: <20230109111931.2401851-2-jiangjiacheng@huawei.com> In-Reply-To: <20230109111931.2401851-1-jiangjiacheng@huawei.com> References: <20230109111931.2401851-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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.7 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: 1673263626438100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiang Jiacheng --- 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 12:12:21 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=1673263575; cv=none; d=zohomail.com; s=zohoarc; b=iWmBjHJZanhOhqK6E/8iiERc5g3+0jUe9I/8/Ca/C120wUw304Dmnze3jhUJRJCWIrkbkHUSKX1PyMnHyfySttmjNrKTsgfbaoDv2iTnBbTm8d8EYsxBdf+8hpRi77hsXxpTb8HRyzG3axTp3m6/BylBQDvlK5dPtv5rcxVQom8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673263575; 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=daqzuB69fzO7oUb7lyCMD0DGRdMOBs7pXI5RpmEFS70=; b=Oq24toGjdCSdMUPgJCHZ4fZxnhdOlylsQ6qfmiEbx16Qyr65zyGc2GjRAW+cW7EMRzURNxzKQpuKLSgNaaMAUzvgGBRUzYjFj1gvu3ocn8WVDATcV8C/+ubkaNr2f30a9SE03y80vJxq8Ug8Odt+HghkFad5/iBfo1JxOywAFh0= 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 1673263575866962.5923082719274; Mon, 9 Jan 2023 03:26:15 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-152-E9JrSPmOPdGNBIvAQvvepQ-1; Mon, 09 Jan 2023 06:26:12 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D29F22999B3D; Mon, 9 Jan 2023 11:26:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCC2F2026D68; Mon, 9 Jan 2023 11:26: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 7E0D5194706C; Mon, 9 Jan 2023 11:26:09 +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 5BE081946586 for ; Mon, 9 Jan 2023 11:26:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4E4CE1121318; Mon, 9 Jan 2023 11:26:08 +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 469501121314 for ; Mon, 9 Jan 2023 11:26:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 2194F88B7A0 for ; Mon, 9 Jan 2023 11:26:08 +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-449-PT5nQN8JNBmNWvnGciBChQ-1; Mon, 09 Jan 2023 06:26:04 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NrBRb09NGznTZ1; Mon, 9 Jan 2023 19:24:27 +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; Mon, 9 Jan 2023 19:25:59 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673263574; 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=daqzuB69fzO7oUb7lyCMD0DGRdMOBs7pXI5RpmEFS70=; b=C930Xg2odZOtw8MoxGk7K/TGtt45KL+GxzVTiPfd4D7EW5A4YVbILno9Aqao/9y0yI5n/4 LBzZHKmTxDd6iOb6XKXZltG0CA/kdN8m/yG8QemDMnpczwCqBQKopupy7rVTRXWb7gxVAb W/hpP9gFLSbGoQx2eIu/3pl6VyWYAqI= X-MC-Unique: E9JrSPmOPdGNBIvAQvvepQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: PT5nQN8JNBmNWvnGciBChQ-1 From: Jiang Jiacheng To: , , , Subject: [PATCH 2/3] src/tests: use g_autoptr for virNWFilterDef and virNWFilterRuleDef Date: Mon, 9 Jan 2023 19:19:30 +0800 Message-ID: <20230109111931.2401851-3-jiangjiacheng@huawei.com> In-Reply-To: <20230109111931.2401851-1-jiangjiacheng@huawei.com> References: <20230109111931.2401851-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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.4 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: 1673263576315100001 Content-Type: text/plain; charset="utf-8" Use g_autoptr() for virNWFilterDef and virNWFilterRuleDef and remove unnecessary label. Signed-off-by: Jiang Jiacheng --- src/conf/nwfilter_conf.c | 44 ++++++++++++++-------------------- src/conf/virnwfilterobj.c | 19 +++++++-------- src/nwfilter/nwfilter_driver.c | 7 +++--- tests/nwfilterxml2xmltest.c | 22 +++++++---------- 4 files changed, 37 insertions(+), 55 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 5453b6db05..382dafb13b 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/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c index 2e75e90cf1..2a2d877f49 100644 --- a/src/conf/virnwfilterobj.c +++ b/src/conf/virnwfilterobj.c @@ -564,37 +564,34 @@ virNWFilterObjListLoadConfig(virNWFilterObjList *nwfi= lters, const char *configDir, const char *name) { - virNWFilterDef *def =3D NULL; + g_autoptr(virNWFilterDef) def =3D NULL; virNWFilterObj *obj; g_autofree char *configFile =3D NULL; =20 if (!(configFile =3D virFileBuildPath(configDir, name, ".xml"))) - goto error; + return NULL; =20 if (!(def =3D virNWFilterDefParse(NULL, configFile, 0))) - goto error; + return NULL; =20 if (STRNEQ(name, def->name)) { virReportError(VIR_ERR_XML_ERROR, _("network filter config filename '%s' " "does not match name '%s'"), configFile, def->name); - goto error; + return NULL; } =20 /* We generated a UUID, make it permanent by saving the config to disk= */ if (!def->uuid_specified && virNWFilterSaveConfig(configDir, def) < 0) - goto error; + return NULL; =20 - if (!(obj =3D virNWFilterObjListAssignDef(nwfilters, def))) - goto error; + if (!(obj =3D virNWFilterObjListAssignDef(nwfilters, + g_steal_pointer(&def)))) + return NULL; =20 return obj; - - error: - virNWFilterDefFree(def); - return NULL; } =20 =20 diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 8e45096eaa..be21aa12c2 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -531,7 +531,7 @@ nwfilterDefineXMLFlags(virConnectPtr conn, unsigned int flags) { VIR_LOCK_GUARD lock =3D virLockGuardLock(&driverMutex); - virNWFilterDef *def; + g_autoptr(virNWFilterDef) def =3D NULL; virNWFilterObj *obj =3D NULL; virNWFilterDef *objdef; virNWFilterPtr nwfilter =3D NULL; @@ -552,10 +552,10 @@ nwfilterDefineXMLFlags(virConnectPtr conn, goto cleanup; =20 VIR_WITH_MUTEX_LOCK_GUARD(&driver->updateLock) { - if (!(obj =3D virNWFilterObjListAssignDef(driver->nwfilters, def))) + if (!(obj =3D virNWFilterObjListAssignDef(driver->nwfilters, + g_steal_pointer(&def)))) goto cleanup; } - def =3D NULL; objdef =3D virNWFilterObjGetDef(obj); =20 if (virNWFilterSaveConfig(driver->configDir, objdef) < 0) { @@ -566,7 +566,6 @@ nwfilterDefineXMLFlags(virConnectPtr conn, nwfilter =3D virGetNWFilter(conn, objdef->name, objdef->uuid); =20 cleanup: - virNWFilterDefFree(def); if (obj) virNWFilterObjUnlock(obj); return nwfilter; 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 From nobody Sat May 18 12:12:21 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=1673263579; cv=none; d=zohomail.com; s=zohoarc; b=j6Jr+mtAfhEwdoI4kKUebDhaiEIwK9XRzR0E6kRhHibHmxzVlEd2gmdYuY9fVCIm4m6UVtDQubocCKIxxc/AmcltdVxIJoFB2gUrczk5FSMObk1HOONjPIApho/g97BUK6S09CsloEz43WMDc7NCp9ZWFdreUkC2cGBPhoCLd0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673263579; 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=dvQ0ZF3J2jr3O8NkUuP1gmbAGLdf/bZZ4j2xGfvfDMI=; b=MprLiwu93ckz+qnGCCGXW5yxyqTjK5NI/JChW8FuolP/tW85if/cYX+f32MjYlZagw7Zfd7S/sbn8tjIFCrwoSTbUzsGIlflByYNmMh9i/Zm7bsmzTPtUUPL7WRq+DU1Yzs+mbIzU59YQ40eeXLu7U68LRZG38PfSaOqPiCtsVo= 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 1673263579657156.38849773814763; Mon, 9 Jan 2023 03:26:19 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-172-V1mY2-0_Nwqddu8APOmx7g-1; Mon, 09 Jan 2023 06:26:12 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E5882999B2A; Mon, 9 Jan 2023 11:26:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08DBB2026D4B; Mon, 9 Jan 2023 11:26:11 +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 C06F01947B93; Mon, 9 Jan 2023 11:26:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C37271946586 for ; Mon, 9 Jan 2023 11:26:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A684B42220; Mon, 9 Jan 2023 11:26:08 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E95F175AD for ; Mon, 9 Jan 2023 11:26:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 7F6DB85A588 for ; Mon, 9 Jan 2023 11:26:08 +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-303-H_gFs0TnOi2mMwPlgawR7A-1; Mon, 09 Jan 2023 06:26:04 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NrBNg0cxfzJq8F; Mon, 9 Jan 2023 19:21:55 +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; Mon, 9 Jan 2023 19:26:00 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673263578; 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=dvQ0ZF3J2jr3O8NkUuP1gmbAGLdf/bZZ4j2xGfvfDMI=; b=JJk1pjwVGx4rl0cJA+8C6KyrQ+hvs7lAVHURpZDEjPJA3NOgknLlKU5w1llQnoD01K6iYt 5z/L5Pmn1nhEpEd7OGWrzSCXdOT+KtiiuALT9X40g1m/ovp7zEmhOgtnczHsh76Wo7uNmL TFVRnNDuMyM/q2IKLn1htRNdbwEaHBI= X-MC-Unique: V1mY2-0_Nwqddu8APOmx7g-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: H_gFs0TnOi2mMwPlgawR7A-1 From: Jiang Jiacheng To: , , , Subject: [PATCH 3/3] virNWFilterSaveConfig: remove the unnecessary variable 'ret' Date: Mon, 9 Jan 2023 19:19:31 +0800 Message-ID: <20230109111931.2401851-4-jiangjiacheng@huawei.com> In-Reply-To: <20230109111931.2401851-1-jiangjiacheng@huawei.com> References: <20230109111931.2401851-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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.5 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.4 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: 1673263580254100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiang Jiacheng Reviewed-by: J=C3=A1n Tomko --- src/conf/nwfilter_conf.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 382dafb13b..8d198a7bb1 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2684,7 +2684,6 @@ int virNWFilterSaveConfig(const char *configDir, virNWFilterDef *def) { - int ret =3D -1; g_autofree char *xml =3D NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; g_autofree char *configFile =3D NULL; @@ -2696,11 +2695,10 @@ virNWFilterSaveConfig(const char *configDir, return -1; =20 virUUIDFormat(def->uuid, uuidstr); - ret =3D virXMLSaveFile(configFile, - virXMLPickShellSafeComment(def->name, uuidstr), - "nwfilter-edit", xml); =20 - return ret; + return virXMLSaveFile(configFile, + virXMLPickShellSafeComment(def->name, uuidstr), + "nwfilter-edit", xml); } =20 =20 --=20 2.33.0