From nobody Mon Feb 9 10:54:30 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=1620201778; cv=none; d=zohomail.com; s=zohoarc; b=EIQS8+5nEQ842qEZr/CQJLtUkYQlTxZf2fZUbEhVBOoImkjzHTaKFp1e7mlu/lSYF2zskr/paYgKsEGjMf4mjJ5m29/IsL5JyXExa3PhiyPZOke9dxcGgQjeIgx89oNzhvodRrKAphTpyXiBtH8GrzgHj5R7oI6Gwbeof5OW4Rc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620201778; 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=JsktfPDVPAC5U17PB2+gzq6oyRsOmf6STqP/TuG+SSs=; b=NWcnfg0BB8Yh9rj26A5kbKqxb9JZi3LYFH74h/ac5ywppCbs7uGRW0AsFmqXRAqdgguuIqDZgM69XGyE+83KwH9lyj8i3DEg5fkpgg83OnzxZ2q4O1GBoWmIcP2YxKK1rbUqpzRQnASZHj5o3PDnexo2mBJ30Uff6418nW30T2w= 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 1620201778856401.9470573533562; Wed, 5 May 2021 01:02:58 -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-249-xPngLNMsMdWVGL9Sp0ulpw-1; Wed, 05 May 2021 04:02:55 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9AEB8BBEE5; Wed, 5 May 2021 08:02:49 +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 429D3131D5; Wed, 5 May 2021 08:02:49 +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 0B3CC55350; Wed, 5 May 2021 08:02:49 +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 14582aeO007825 for ; Wed, 5 May 2021 04:02:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5D8075D9E2; Wed, 5 May 2021 08:02:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id D148A5D9D5 for ; Wed, 5 May 2021 08:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620201777; 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=JsktfPDVPAC5U17PB2+gzq6oyRsOmf6STqP/TuG+SSs=; b=gCeduHyGRTUqthVSRiEAWdMzgCe9jp3tjIt2YRXl3HwC5guNSaC0ifrbyfosbSO1sN/GfV yzYNdeo7ANNO6N7nldJcphY+XG+QwxLRLBLqfF30maUA38BVCMy7vH0yXYBhFzt4Lz51pj NnmqOxb7GKwy44UkB9ZR+1E1BC6zBDA= X-MC-Unique: xPngLNMsMdWVGL9Sp0ulpw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/5] virCapabilitiesHostNUMAInitReal: Bring variables into loop Date: Wed, 5 May 2021 10:02:24 +0200 Message-Id: <66015045325126f2cf9ab7b67c7951e9ab44823a.1620201674.git.mprivozn@redhat.com> 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.84 on 10.5.11.23 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) Content-Type: text/plain; charset="utf-8" Some variables are needed only inside for() loop. They were declared at the beginning of the function because of VIR_FREE() calls, but since they are auto-freed they can be declared inside the loop. Signed-off-by: Michal Privoznik --- src/conf/capabilities.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index c487229ae8..1dae6d38cc 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1596,22 +1596,22 @@ static int virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps) { int n; - unsigned long long memory; virCapsHostNUMACellCPU *cpus =3D NULL; - g_autoptr(virBitmap) cpumap =3D NULL; - g_autofree virCapsHostNUMACellSiblingInfo *siblings =3D NULL; - int nsiblings =3D 0; - g_autofree virCapsHostNUMACellPageInfo *pageinfo =3D NULL; - int npageinfo; int ret =3D -1; int ncpus =3D 0; - int cpu; int max_node; =20 if ((max_node =3D virNumaGetMaxNode()) < 0) goto cleanup; =20 for (n =3D 0; n <=3D max_node; n++) { + g_autoptr(virBitmap) cpumap =3D NULL; + g_autofree virCapsHostNUMACellSiblingInfo *siblings =3D NULL; + int nsiblings =3D 0; + g_autofree virCapsHostNUMACellPageInfo *pageinfo =3D NULL; + int npageinfo; + unsigned long long memory; + int cpu; size_t i; =20 if ((ncpus =3D virNumaGetNodeCPUs(n, &cpumap)) < 0) { @@ -1645,8 +1645,6 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps) ncpus, &cpus, nsiblings, &siblings, npageinfo, &pageinfo); - virBitmapFree(cpumap); - cpumap =3D NULL; } =20 ret =3D 0; --=20 2.26.3