From nobody Mon Feb 9 03:14:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1568636246; cv=none; d=zoho.com; s=zohoarc; b=bkRLj0228aKthZXCMlcEj6PoDYTxgY3PcGjmSlsyF2mZ9i1ZRkzbApNYLsp61zIQv4s6bo996LvdDIIRXVBluDWe2Saz6T4nzPhpbVq4I0/C8iMmPUTeS5K1Hl3rzHExOP6fBozKXr+1UtJ3ZVTtDhB1mxJEKMIQsOXuEvgcnBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568636246; 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:ARC-Authentication-Results; bh=URjTYvU0FAZDFflsWfMAyxN5CEdxEkhanDrVNlixiVo=; b=eLISmpSKICMrJemIiyS5Ad3z8nPH8ONaLuUZo09SeRQsBzrYX7vy6IuX7lQ0CHKEah/Xbz1qhEOcZd57+LWCY8HNW6j51S07wHg6HzMZxiENv40CKv63xO0V84mSsLogMmY/pjHc1aS3U+EkI4D99zMG2NPjFbaXDF4cPqg2RPU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568636246980851.7910401570064; Mon, 16 Sep 2019 05:17:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 36761315C015; Mon, 16 Sep 2019 12:17:24 +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 DDAB960BE1; Mon, 16 Sep 2019 12:17: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 369E683543; Mon, 16 Sep 2019 12:17: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 x8GCHL88024497 for ; Mon, 16 Sep 2019 08:17:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54973196AE; Mon, 16 Sep 2019 12:17:21 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1089A20C for ; Mon, 16 Sep 2019 12:17:20 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 16 Sep 2019 14:17:05 +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 Subject: [libvirt] [PATCH 2/9] conf: network: Use VIR_AUTOPTR in virNetworkDefUpdateSection 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 16 Sep 2019 12:17:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add automatic cleanup for variables of xmlDoc and xmlXPathContext type to remove the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/conf/network_conf.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 585c87a9f4..b65fb1f67a 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -3640,57 +3640,56 @@ virNetworkDefUpdateSection(virNetworkDefPtr def, const char *xml, unsigned int flags) /* virNetworkUpdateFlags */ { - int ret =3D -1; - xmlDocPtr doc; - xmlXPathContextPtr ctxt =3D NULL; + VIR_AUTOPTR(xmlDoc) doc =3D NULL; + VIR_AUTOPTR(xmlXPathContext) ctxt =3D NULL; if (!(doc =3D virXMLParseStringCtxt(xml, _("network_update_xml"), &ctx= t))) - goto cleanup; + return -1; switch (section) { case VIR_NETWORK_SECTION_BRIDGE: - ret =3D virNetworkDefUpdateBridge(def, command, parentIndex, ctxt, = flags); + return virNetworkDefUpdateBridge(def, command, parentIndex, ctxt, = flags); break; case VIR_NETWORK_SECTION_DOMAIN: - ret =3D virNetworkDefUpdateDomain(def, command, parentIndex, ctxt,= flags); + return virNetworkDefUpdateDomain(def, command, parentIndex, ctxt, = flags); break; case VIR_NETWORK_SECTION_IP: - ret =3D virNetworkDefUpdateIP(def, command, parentIndex, ctxt, fla= gs); + return virNetworkDefUpdateIP(def, command, parentIndex, ctxt, flag= s); break; case VIR_NETWORK_SECTION_IP_DHCP_HOST: - ret =3D virNetworkDefUpdateIPDHCPHost(def, command, + return virNetworkDefUpdateIPDHCPHost(def, command, parentIndex, ctxt, flags); break; case VIR_NETWORK_SECTION_IP_DHCP_RANGE: - ret =3D virNetworkDefUpdateIPDHCPRange(def, command, + return virNetworkDefUpdateIPDHCPRange(def, command, parentIndex, ctxt, flags); break; case VIR_NETWORK_SECTION_FORWARD: - ret =3D virNetworkDefUpdateForward(def, command, + return virNetworkDefUpdateForward(def, command, parentIndex, ctxt, flags); break; case VIR_NETWORK_SECTION_FORWARD_INTERFACE: - ret =3D virNetworkDefUpdateForwardInterface(def, command, + return virNetworkDefUpdateForwardInterface(def, command, parentIndex, ctxt, flags= ); break; case VIR_NETWORK_SECTION_FORWARD_PF: - ret =3D virNetworkDefUpdateForwardPF(def, command, + return virNetworkDefUpdateForwardPF(def, command, parentIndex, ctxt, flags); break; case VIR_NETWORK_SECTION_PORTGROUP: - ret =3D virNetworkDefUpdatePortGroup(def, command, + return virNetworkDefUpdatePortGroup(def, command, parentIndex, ctxt, flags); break; case VIR_NETWORK_SECTION_DNS_HOST: - ret =3D virNetworkDefUpdateDNSHost(def, command, + return virNetworkDefUpdateDNSHost(def, command, parentIndex, ctxt, flags); break; case VIR_NETWORK_SECTION_DNS_TXT: - ret =3D virNetworkDefUpdateDNSTxt(def, command, parentIndex, ctxt,= flags); + return virNetworkDefUpdateDNSTxt(def, command, parentIndex, ctxt, = flags); break; case VIR_NETWORK_SECTION_DNS_SRV: - ret =3D virNetworkDefUpdateDNSSrv(def, command, parentIndex, ctxt,= flags); + return virNetworkDefUpdateDNSSrv(def, command, parentIndex, ctxt, = flags); break; default: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", @@ -3698,8 +3697,5 @@ virNetworkDefUpdateSection(virNetworkDefPtr def, break; } - cleanup: - xmlFreeDoc(doc); - xmlXPathFreeContext(ctxt); - return ret; + return -1; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list