From nobody Sun Feb 8 22:20:45 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=1568636263; cv=none; d=zoho.com; s=zohoarc; b=jwRJkDDN700mPemargcxeFdB0h8xA8MFN1IW3ocI8XVMnaD/SKygEm8eWxTcsf1iiRzqpx/lwot7RkANDvu5fl/dj/bJPelwcNOWrseaWlArrC3amsLE3wWX7Q1ZFN3f587onVjkBvM2Mi8yWuqB3sgsCleZR/HiCr5gHhfgfl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568636263; 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=5qVDttex3GajnD6oDwIpEqk8wBylT+NYzBHR8kRmFJo=; b=jCVO9lW9WJDAfHRK8Pq6vQh0XpU4WVv3tKP9m7+fERPcmKW/qPpYzkt2VuM77xsqaHKeTWNddeT0Y343wNVbKeX1CmZdyryht4cVD/fw5wkfMzNIEQyH5bXwnnLHlvBPDEpMjPluZMnpmdZzJ5DXQIV+KtmksczuIGY36/FTkQc= 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 1568636263931137.40769069258306; Mon, 16 Sep 2019 05:17:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 376F8315C01B; Mon, 16 Sep 2019 12:17:42 +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 123D85D6C8; Mon, 16 Sep 2019 12:17:42 +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 C30738354D; Mon, 16 Sep 2019 12:17:41 +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 x8GCHPL6024529 for ; Mon, 16 Sep 2019 08:17:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 610148D5E; Mon, 16 Sep 2019 12:17:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE5E24115 for ; Mon, 16 Sep 2019 12:17:24 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 16 Sep 2019 14:17:08 +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 5/9] conf: Use VIR_AUTOPTR for xmlDoc and xmlXPath objects 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.15 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:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Refactor functions using these two object types together with VIR_AUTOPTR. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/conf/domain_conf.c | 16 +++++----------- src/conf/storage_conf.c | 20 +++++++------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0ab69a9366..5fec2e5220 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16508,20 +16508,19 @@ virDomainDiskDefParse(const char *xmlStr, virDomainXMLOptionPtr xmlopt, unsigned int flags) { - xmlDocPtr xml; - xmlXPathContextPtr ctxt =3D NULL; - virDomainDiskDefPtr disk =3D NULL; + VIR_AUTOPTR(xmlDoc) xml =3D NULL; + VIR_AUTOPTR(xmlXPathContext) ctxt =3D NULL; virSecurityLabelDefPtr *seclabels =3D NULL; size_t nseclabels =3D 0; if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &c= txt))) - goto cleanup; + return NULL; if (!virXMLNodeNameEqual(ctxt->node, "disk")) { virReportError(VIR_ERR_XML_ERROR, _("expecting root element of 'disk', not '%s'"), ctxt->node->name); - goto cleanup; + return NULL; } if (def) { @@ -16529,13 +16528,8 @@ virDomainDiskDefParse(const char *xmlStr, nseclabels =3D def->nseclabels; } - disk =3D virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt, + return virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt, seclabels, nseclabels, flags); - - cleanup: - xmlFreeDoc(xml); - xmlXPathFreeContext(ctxt); - return disk; } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index f6de3687ab..fcd1701d37 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -695,36 +695,30 @@ virStoragePoolSourcePtr virStoragePoolDefParseSourceString(const char *srcSpec, int pool_type) { - xmlDocPtr doc =3D NULL; + VIR_AUTOPTR(xmlDoc) doc =3D NULL; xmlNodePtr node =3D NULL; - xmlXPathContextPtr xpath_ctxt =3D NULL; - virStoragePoolSourcePtr ret =3D NULL; + VIR_AUTOPTR(xmlXPathContext) xpath_ctxt =3D NULL; VIR_AUTOPTR(virStoragePoolSource) def =3D NULL; if (!(doc =3D virXMLParseStringCtxt(srcSpec, _("(storage_source_specification)"), &xpath_ctxt))) - goto cleanup; + return NULL; if (VIR_ALLOC(def) < 0) - goto cleanup; + return NULL; if (!(node =3D virXPathNode("/source", xpath_ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("root element was not source")); - goto cleanup; + return NULL; } if (virStoragePoolDefParseSource(xpath_ctxt, def, pool_type, node) < 0) - goto cleanup; - - VIR_STEAL_PTR(ret, def); - cleanup: - xmlFreeDoc(doc); - xmlXPathFreeContext(xpath_ctxt); + return NULL; - return ret; + VIR_RETURN_PTR(def); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list