From nobody Sun Feb 8 21:29:04 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639052388; cv=none; d=zohomail.com; s=zohoarc; b=D//HYDd53hFY0P/eUwTIhkvUrfQem6wJmyfFO+36JRP747XpVHScB4WNtNqrddIBNyZWGgCSJOIEQDexfyXECGdm9Z2YtsyRHfAdkh3ggk9TEYQmkzdqpNdLI5i9SeYHncU677SCygLmD20AdcGqH1s4aFWvK5KTr3Xwwm6gw44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052388; 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; bh=1d2fo6G8o/eJq511BuGshNhmVKdaEj2zIHHoIr9Ku58=; b=F8IIgEnDwYYrRBUPwqvWZddr+b6Oz7NZDO5aFvyzU7MisQC/bQMEfRI3lkSTrRtatjRn8fwFFVFuHh2ZyT2UL8gd54BEtYhMjJKZbd8WpDOMA79hTvR+rL825t1U784bLOpH+zK7V180usAjuIM0BHL6J1COiQzxCJcME7x4joo= 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=pass header.from= (p=none dis=none) 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 1639052388989201.8811518482264; Thu, 9 Dec 2021 04:19:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-219-tNJ4TsyFO3GKGoZF87JnuA-1; Thu, 09 Dec 2021 07:19:44 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 843632F26; Thu, 9 Dec 2021 12:19:39 +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 3EC3160657; Thu, 9 Dec 2021 12:19:39 +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 0EC614A707; Thu, 9 Dec 2021 12:19:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9CJbRB013937 for ; Thu, 9 Dec 2021 07:19:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1A23B17DBA; Thu, 9 Dec 2021 12:19:37 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73F775E24E for ; Thu, 9 Dec 2021 12:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052388; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=1d2fo6G8o/eJq511BuGshNhmVKdaEj2zIHHoIr9Ku58=; b=C4jldMcb4EwOQpZdNKA3S5pcrZcrU+6xoaPvzGC4BYj9jm+UO6L7EYeaK6QC7DQiPaLrUa 9G5xOK8oNhqpFfjdMVgyCNW/zHKNB4MN38THB3JOsIOfTjpx7KobC+yA39kPcf6MtxlUtX hn20h1GOAdF43HvrqEmfW5ezAx7Z4zI= X-MC-Unique: tNJ4TsyFO3GKGoZF87JnuA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/36] virDomainNumatuneParseXML: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:09 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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.11 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) X-ZM-MESSAGEID: 1639052390676100002 Content-Type: text/plain; charset="utf-8" Use automatic memory clearing for the temporary strings and bitmap and remove the cleanup section. There are multiple temporary strings added so that we don't reuse one. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/numa_conf.c | 52 +++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 9a9b5f4b60..3bc1f63a5d 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -224,22 +224,23 @@ virDomainNumatuneParseXML(virDomainNuma *numa, bool placement_static, xmlXPathContextPtr ctxt) { - char *tmp =3D NULL; + g_autofree char *modestr =3D NULL; int mode =3D -1; int n =3D 0; + g_autofree char *placementstr =3D NULL; int placement =3D -1; - int ret =3D -1; - virBitmap *nodeset =3D NULL; + g_autofree char *nodesetstr =3D NULL; + g_autoptr(virBitmap) nodeset =3D NULL; xmlNodePtr node =3D NULL; if (virXPathInt("count(./numatune)", ctxt, &n) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract numatune nodes")); - goto cleanup; + return -1; } else if (n > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _("only one numatune is supported")); - goto cleanup; + return -1; } node =3D virXPathNode("./numatune/memory[1]", ctxt); @@ -248,34 +249,29 @@ virDomainNumatuneParseXML(virDomainNuma *numa, placement =3D VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO; if (node) { - if ((tmp =3D virXMLPropString(node, "mode")) && - (mode =3D virDomainNumatuneMemModeTypeFromString(tmp)) < 0) { + if ((modestr =3D virXMLPropString(node, "mode")) && + (mode =3D virDomainNumatuneMemModeTypeFromString(modestr)) < 0= ) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unsupported NUMA memory tuning mode '%s'"), = tmp); - goto cleanup; + _("Unsupported NUMA memory tuning mode '%s'"), = modestr); + return -1; } - VIR_FREE(tmp); - if ((tmp =3D virXMLPropString(node, "placement")) && - (placement =3D virDomainNumatunePlacementTypeFromString(tmp)) = < 0) { + if ((placementstr =3D virXMLPropString(node, "placement")) && + (placement =3D virDomainNumatunePlacementTypeFromString(placem= entstr)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unsupported NUMA memory placement mode '%s'"= ), tmp); - goto cleanup; + _("Unsupported NUMA memory placement mode '%s'"= ), placementstr); + return -1; } - VIR_FREE(tmp); - tmp =3D virXMLPropString(node, "nodeset"); - if (tmp) { - if (virBitmapParse(tmp, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; + if ((nodesetstr =3D virXMLPropString(node, "nodeset"))) { + if (virBitmapParse(nodesetstr, &nodeset, VIR_DOMAIN_CPUMASK_LE= N) < 0) + return -1; if (virBitmapIsAllClear(nodeset)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid value of 'nodeset': %s"), tmp); - goto cleanup; + _("Invalid value of 'nodeset': %s"), nodese= tstr); + return -1; } - - VIR_FREE(tmp); } } @@ -284,16 +280,12 @@ virDomainNumatuneParseXML(virDomainNuma *numa, placement, mode, nodeset) < 0) - goto cleanup; + return -1; if (virDomainNumatuneNodeParseXML(numa, ctxt) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - virBitmapFree(nodeset); - VIR_FREE(tmp); - return ret; + return 0; } int --=20 2.31.1