From nobody Tue Feb 10 12:57:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1620745481; cv=none; d=zohomail.com; s=zohoarc; b=j7O2s2erxiH+pnVnc1z+rNnF/BKXZ405Vji7WNEwZCd6wpE6RdVif4eImkGLVCg95CzA2NdrSFOA92jH4zyLhqysIpZdXQBI/UIMgFMt3od0a6Jkuzr6nimF2GYQoW2pHegMxG2pW4GHhwRn4cYY/Z/o+Y1xQB8Gi04J8IPRpsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745481; 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=i5bAPphsLef1euxf08kMA88bbRyGq6uPvaGs1vRH/4g=; b=kt1cLcYrRNxOUZNAp0gPTKeq/FOsAsFBfe4K+5hpuhBVaf66/G7ZeY05RnIeZIS0sFL1c8HVPl7GUzUg/MP81vPHlS8KXqiQmu9W6AHO+nshjnNwWLTciTPTFb0MNP6CIhD4A6OaYITUx/aVzcRl0X9k4H2fNMS4SmIjTaha3Y4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620745481374670.3333234460781; Tue, 11 May 2021 08:04:41 -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-557-AutyIUVDMDCOi0yQLPXRSw-1; Tue, 11 May 2021 11:02:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E45FCFC89; Tue, 11 May 2021 15:02:26 +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 C24AC5DEAD; Tue, 11 May 2021 15:02:26 +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 76A8B1801267; Tue, 11 May 2021 15:02:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14BF25dg005539 for ; Tue, 11 May 2021 11:02:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 297041B427; Tue, 11 May 2021 15:02:05 +0000 (UTC) Received: from work.redhat.com (ovpn-113-41.ams2.redhat.com [10.36.113.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 726AE60CDE; Tue, 11 May 2021 15:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745356; 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=i5bAPphsLef1euxf08kMA88bbRyGq6uPvaGs1vRH/4g=; b=SnCYlDHmvB3+jRNvLdgOM8eDpe9bYEm46pw03LRsnR4NatmRGPyGi/CuIB2RQpbCp5M1sj sUH9cWJOtI4cztLRydDcsKxrCAlAo1qFQBEfkfPDw6FbtFfU1/O+aZG0PLqUuILOIKJohn iXuDLEGhhuU0WFW2NFVqGeMCXwFlyGw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745480; 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=i5bAPphsLef1euxf08kMA88bbRyGq6uPvaGs1vRH/4g=; b=E6lBrDsWmZEKD2B579s0swXYBarHSxlpwEGXnWiDs5SJYrXuw1Pwzwyg1EJOWekEUR/1Ym Fk3vu/jQNL5mVIXXDlMp6LOQv2msX6iqVJeJHr+A/2XyysbnigagfzK9pkoA0Hr+mXxQ0I xxvpcKpKrNymYg5E29TiBz6an+Zn6+U= X-MC-Unique: AutyIUVDMDCOi0yQLPXRSw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 06/10] virDomainNumaDefParseXML: Use g_autofree Date: Tue, 11 May 2021 17:01:53 +0200 Message-Id: <20210511150157.26027-7-twiederh@redhat.com> In-Reply-To: <20210511150157.26027-1-twiederh@redhat.com> References: <20210511150157.26027-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/conf/numa_conf.c | 49 +++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 27aac87a8d..abb39a36ac 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -933,11 +933,9 @@ int virDomainNumaDefParseXML(virDomainNuma *def, xmlXPathContextPtr ctxt) { - xmlNodePtr *nodes =3D NULL; - char *tmp =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; int n; size_t i, j; - int ret =3D -1; =20 /* check if NUMA definition is present */ if (!virXPathNode("./cpu/numa[1]", ctxt)) @@ -946,7 +944,7 @@ virDomainNumaDefParseXML(virDomainNuma *def, if ((n =3D virXPathNodeSet("./cpu/numa[1]/cell", ctxt, &nodes)) <=3D 0= ) { virReportError(VIR_ERR_XML_ERROR, "%s", _("NUMA topology defined without NUMA cells")); - goto cleanup; + return -1; } =20 def->mem_nodes =3D g_new0(struct _virDomainNumaNode, n); @@ -954,12 +952,13 @@ virDomainNumaDefParseXML(virDomainNuma *def, =20 for (i =3D 0; i < n; i++) { VIR_XPATH_NODE_AUTORESTORE(ctxt) + g_autofree char *tmp =3D NULL; int rc; unsigned int cur_cell; =20 if ((rc =3D virXMLPropUInt(nodes[i], "id", 10, VIR_XML_PROP_NONE, &cur_cell)) < 0) - goto cleanup; + return -1; =20 if (rc =3D=3D 0) cur_cell =3D i; @@ -970,25 +969,24 @@ virDomainNumaDefParseXML(virDomainNuma *def, _("Exactly one 'cell' element per guest " "NUMA cell allowed, non-contiguous ranges or " "ranges not starting from 0 are not allowed")= ); - goto cleanup; + return -1; } =20 if (def->mem_nodes[cur_cell].mem) { virReportError(VIR_ERR_XML_ERROR, _("Duplicate NUMA cell info for cell id '%u'"), cur_cell); - goto cleanup; + return -1; } =20 if ((tmp =3D virXMLPropString(nodes[i], "cpus"))) { g_autoptr(virBitmap) cpumask =3D NULL; =20 if (virBitmapParse(tmp, &cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; + return -1; =20 if (!virBitmapIsAllClear(cpumask)) def->mem_nodes[cur_cell].cpumask =3D g_steal_pointer(&cpum= ask); - VIR_FREE(tmp); } =20 for (j =3D 0; j < n; j++) { @@ -1002,38 +1000,38 @@ virDomainNumaDefParseXML(virDomainNuma *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("NUMA cells %u and %zu have overlapping v= CPU ids"), cur_cell, j); - goto cleanup; + return -1; } } =20 ctxt->node =3D nodes[i]; if (virDomainParseMemory("./@memory", "./@unit", ctxt, &def->mem_nodes[cur_cell].mem, true, fals= e) < 0) - goto cleanup; + return -1; =20 if (virXMLPropEnum(nodes[i], "memAccess", virDomainMemoryAccessTypeFromString, VIR_XML_PROP_NONZERO, &def->mem_nodes[cur_cell].memAccess) < 0) - goto cleanup; + return -1; =20 if (virXMLPropTristateBool(nodes[i], "discard", VIR_XML_PROP_NONE, &def->mem_nodes[cur_cell].discard) < 0) - goto cleanup; + return -1; =20 /* Parse NUMA distances info */ if (virDomainNumaDefNodeDistanceParseXML(def, ctxt, cur_cell) < 0) - goto cleanup; + return -1; =20 /* Parse cache info */ if (virDomainNumaDefNodeCacheParseXML(def, ctxt, cur_cell) < 0) - goto cleanup; + return -1; } =20 VIR_FREE(nodes); if ((n =3D virXPathNodeSet("./cpu/numa[1]/interconnects[1]/latency|" "./cpu/numa[1]/interconnects[1]/bandwidth", c= txt, &nodes)) < 0) - goto cleanup; + return -1; =20 def->interconnects =3D g_new0(virDomainNumaInterconnect, n); for (i =3D 0; i < n; i++) { @@ -1049,7 +1047,7 @@ virDomainNumaDefParseXML(virDomainNuma *def, =20 if (virXMLPropULongLong(nodes[i], "value", 10, VIR_XML_PROP_REQUIRED, &value) < 0) - goto cleanup; + return -1; } else if (virXMLNodeNameEqual(nodes[i], "bandwidth")) { VIR_XPATH_NODE_AUTORESTORE(ctxt) type =3D VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_BANDWIDTH; @@ -1057,7 +1055,7 @@ virDomainNumaDefParseXML(virDomainNuma *def, ctxt->node =3D nodes[i]; =20 if (virDomainParseMemory("./@value", "./@unit", ctxt, &value, = true, false) < 0) - goto cleanup; + return -1; } else { /* Ignore yet unknown child elements. */ continue; @@ -1065,32 +1063,27 @@ virDomainNumaDefParseXML(virDomainNuma *def, =20 if (virXMLPropUInt(nodes[i], "initiator", 10, VIR_XML_PROP_REQUIRE= D, &initiator) < 0) - goto cleanup; + return -1; =20 if (virXMLPropUInt(nodes[i], "target", 10, VIR_XML_PROP_REQUIRED, &target) < 0) - goto cleanup; + return -1; =20 if (virXMLPropUInt(nodes[i], "cache", 10, VIR_XML_PROP_NONE, &cache) < 0) - goto cleanup; + return -1; =20 if (virXMLPropEnum(nodes[i], "type", virDomainMemoryLatencyTypeFro= mString, VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, &accessType) < 0) - goto cleanup; + return -1; =20 def->interconnects[i] =3D (virDomainNumaInterconnect) {type, initi= ator, target, cache, access= Type, value}; def->ninterconnects++; } =20 - ret =3D 0; - - cleanup: - VIR_FREE(nodes); - VIR_FREE(tmp); - return ret; + return 0; } =20 =20 --=20 2.26.3