From nobody Sun Feb 8 21:11:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1639052357; cv=none; d=zohomail.com; s=zohoarc; b=mBYzXNdz4Me7eRFxW0U7o0oYXNxC6YntbkOXVnsQ///GrxE0PttKdOWMIKY4CBileTnN/akKqbi+2aRhwNUP2gYz2SkHEP0lx6Es9BvLx7p+wy1L+EMhEqN9UmKqerCnHIqZtPrWxMyv0SECuOrGoQ/uhT47NyTfsRmu0TJ3QL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052357; 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=cNgd3vZ0pLhr4Yt9ZdDnH7+/PdC4LdgmFx254IPoXjs=; b=X3NTRN2HmeYWQnQ4XLWqpfXUH7oT3W3Z8iz8jVsrg4vH07hXY+lhKJV4kfkxqX4wY2GvScBqfIVsDBaReRfZXVc2oB2qMmIBuazNKLXZE7xQc3jtwxEKIpMobZDdeQPwq7+1rTzmpZDPgqD7kytHJv9Cq350ZGej2c5HvpOXmpk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 16390523576791011.0459886695061; Thu, 9 Dec 2021 04:19:17 -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-408-iamuGocTOQWkbzHUMqrJYQ-1; Thu, 09 Dec 2021 07:19:13 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 010E981CCB4; Thu, 9 Dec 2021 12:19:09 +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 D8A8A68D94; Thu, 9 Dec 2021 12:19:08 +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 AB8491809CBA; Thu, 9 Dec 2021 12:19:08 +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 1B9CJ6cZ013670 for ; Thu, 9 Dec 2021 07:19:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4EDB25ED27; Thu, 9 Dec 2021 12:19:06 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E84E5ED2B for ; Thu, 9 Dec 2021 12:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052356; 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=cNgd3vZ0pLhr4Yt9ZdDnH7+/PdC4LdgmFx254IPoXjs=; b=LVE/gHKZjptM6glWH7Z9ulwVVApCNbpQi8jB1JfiUCRB+SVfKCNOIngQxxlN6nkZWftSG7 TThwOxGytvAVQMsxunosDxaUDi1ZrDwIzmbdMeY31iCDwpNWrMwUfDZDrA88VLbwXATl8N KrN29/CFq+1LFChki2oaO7KK7rJDBjU= X-MC-Unique: iamuGocTOQWkbzHUMqrJYQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/36] conf: capabilities: Clean up freeing of virBitmap Date: Thu, 9 Dec 2021 13:18:07 +0100 Message-Id: <8630ead9b91c47b6082132eb59be141d6efcb652.1639052248.git.pkrempa@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.79 on 10.5.11.16 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: 1639052359394100001 Content-Type: text/plain; charset="utf-8" Use automatic freeing where possible and use g_clear_pointer instead of manual NULL-ing. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/capabilities.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 34295ec4d7..ef594d7241 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -104,10 +104,8 @@ virCapabilitiesClearHostNUMACellCPUTopology(virCapsHos= tNUMACellCPU *cpus, if (!cpus) return; - for (i =3D 0; i < ncpus; i++) { - virBitmapFree(cpus[i].siblings); - cpus[i].siblings =3D NULL; - } + for (i =3D 0; i < ncpus; i++) + g_clear_pointer(&cpus[i].siblings, virBitmapFree); } static void @@ -1416,20 +1414,18 @@ virBitmap * virCapabilitiesHostNUMAGetCpus(virCapsHostNUMA *caps, virBitmap *nodemask) { - virBitmap *ret =3D NULL; + g_autoptr(virBitmap) ret =3D NULL; unsigned int maxcpu =3D virCapabilitiesHostNUMAGetMaxcpu(caps); ssize_t node =3D -1; ret =3D virBitmapNew(maxcpu + 1); while ((node =3D virBitmapNextSetBit(nodemask, node)) >=3D 0) { - if (virCapabilitiesHostNUMAGetCellCpus(caps, node, ret) < 0) { - virBitmapFree(ret); + if (virCapabilitiesHostNUMAGetCellCpus(caps, node, ret) < 0) return NULL; - } } - return ret; + return g_steal_pointer(&ret); } --=20 2.31.1