From nobody Fri May 3 10:27:29 2024 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=1639052354; cv=none; d=zohomail.com; s=zohoarc; b=eUzMiQVXMicvdTA0QdZgXMmJ0I/CcbGfuMttBZ44i2ggQx7UEXm4FHuGyDn8kT8PYoo50huQ4cait4qmTQLi41j/lgl0lM204k9zT5uJlTB58fCnDajfpRAHbgwyOVpKm/2U8nSHziwoviLdsaBwMLhfLzYH9+OH0MtiJH8g/+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052354; 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=y9Owu5U4Mrs07Zkb4tyEahTI7iqYRRWlwCu06Ugz89w=; b=mN0JVHPszgxju67CLCiLZqdhq3yB1sbAgAuhZh5mOIjD5PjL/o39kDZaPG3nT3MTaNfH+2INPWj2Lfk1kjapwKNN9RkFqla++fZjVl6/BfH5IDO8rfb6tX7PG0fsSFD9yaZ5AmDVvZielnOzwtFsXd5Qc4Y3NwBGu4TykesVwRs= 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 1639052354203833.8203843015804; Thu, 9 Dec 2021 04:19:14 -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-252-NZLC7Z03P-iES3RUywEqoQ-1; Thu, 09 Dec 2021 07:19:11 -0500 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 3E8DF10B744E; Thu, 9 Dec 2021 12:19:07 +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 EF5A419D9B; Thu, 9 Dec 2021 12:19:06 +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 BF92D4A7CB; Thu, 9 Dec 2021 12:19:06 +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 1B9CJ5TB013659 for ; Thu, 9 Dec 2021 07:19:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0D9C15ED27; Thu, 9 Dec 2021 12:19:05 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70A165ED2A for ; Thu, 9 Dec 2021 12:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052353; 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=y9Owu5U4Mrs07Zkb4tyEahTI7iqYRRWlwCu06Ugz89w=; b=DmlW5/+3zy0BB6vXHSA8iiMtQSbffTqZNDJdK7xrx9gnVSkm6l75WQyPrbCJ/KFFCKv4bm l1in1cprEv/KtKYqYi8U/0MzLZNyd7xRKCejFb9WHbwdWJbvg2AAc43Wg5xnyvw2mHkgmf cDFJc3yqJ85Cyap1GYIwoyN7l7LQEMk= X-MC-Unique: NZLC7Z03P-iES3RUywEqoQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/36] virCapabilitiesInitCaches: Refactor freeing of temporary variables Date: Thu, 9 Dec 2021 13:18:06 +0100 Message-Id: <2fe2eb63421f4e6cff15b542f9ea82858b0c9b03.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.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) X-ZM-MESSAGEID: 1639052354982100001 Content-Type: text/plain; charset="utf-8" Move the 'path' and 'type' variables down to the appropriate block and use automatic freeing for them as well as the temporary virBitmap. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/capabilities.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index cea4803fc8..34295ec4d7 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -2155,11 +2155,9 @@ int virCapabilitiesInitCaches(virCaps *caps) { size_t i =3D 0; - virBitmap *cpus =3D NULL; + g_autoptr(virBitmap) cpus =3D NULL; ssize_t pos =3D -1; int ret =3D -1; - char *path =3D NULL; - char *type =3D NULL; struct dirent *ent =3D NULL; virCapsHostCacheBank *bank =3D NULL; const virResctrlMonitorType montype =3D VIR_RESCTRL_MONITOR_TYPE_CACHE; @@ -2180,9 +2178,7 @@ virCapabilitiesInitCaches(virCaps *caps) while ((pos =3D virBitmapNextSetBit(cpus, pos)) >=3D 0) { int rv =3D -1; g_autoptr(DIR) dirp =3D NULL; - - VIR_FREE(path); - path =3D g_strdup_printf("%s/cpu/cpu%zd/cache/", SYSFS_SYSTEM_PATH= , pos); + g_autofree char *path =3D g_strdup_printf("%s/cpu/cpu%zd/cache/", = SYSFS_SYSTEM_PATH, pos); rv =3D virDirOpenIfExists(&dirp, path); if (rv < 0) @@ -2192,6 +2188,7 @@ virCapabilitiesInitCaches(virCaps *caps) continue; while ((rv =3D virDirRead(dirp, &ent, path)) > 0) { + g_autofree char *type =3D NULL; int kernel_type; unsigned int level; @@ -2242,7 +2239,6 @@ virCapabilitiesInitCaches(virCaps *caps) } bank->type =3D kernel_type; - VIR_FREE(type); for (i =3D 0; i < caps->host.cache.nbanks; i++) { if (virCapsHostCacheBankEquals(bank, caps->host.cache.bank= s[i])) @@ -2284,10 +2280,7 @@ virCapabilitiesInitCaches(virCaps *caps) ret =3D 0; cleanup: - VIR_FREE(type); - VIR_FREE(path); virCapsHostCacheBankFree(bank); - virBitmapFree(cpus); return ret; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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 From nobody Fri May 3 10:27:29 2024 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=1639052359; cv=none; d=zohomail.com; s=zohoarc; b=EtcQauRBwYgTrmECfKLAb3owcaPvRxoENCJfQY40JrSjBOADrliQ/tvbELNxtXw7R+sha/HxYPAlS59U2JzpCVtj83WPmWa2oV9RikT7PVydhv2NLfjn4Zdte/veUpSk9cWzqW1G4IHAaZVMlrlsX5lVNUwbm8RO9yLWEGEwIhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052359; 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=K0clRFcF4d3Ei+rqMiSr/Wb2QKYV//zvUpRNWxPKi+A=; b=ctZS2Nb0wTychZxZ65oMUoE8GXCmGCW8U4RYjFUVkjyva65JNM7Ai0n0XVi2V441Pk0aEyXl4p0bYeJmV+v2xUNdAy7e1OChNb722S3UduMCFrSzrxmcM7ZyaVuqOpW86XUmEVL10j/jg3uPjtXDBoKIB07WllncKR8q9m3mgwg= 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 163905235910669.28991100494454; Thu, 9 Dec 2021 04:19:19 -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-320-dbdF8QBvM9iP3nyOlFw_lA-1; Thu, 09 Dec 2021 07:19:16 -0500 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 49A5410151E0; Thu, 9 Dec 2021 12:19:12 +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 2E64C1972D; Thu, 9 Dec 2021 12:19:12 +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 D62BB4A700; Thu, 9 Dec 2021 12:19:11 +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 1B9CJ7Vx013680 for ; Thu, 9 Dec 2021 07:19:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5937A5ED33; Thu, 9 Dec 2021 12:19:07 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBDD55ED2B for ; Thu, 9 Dec 2021 12:19:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052358; 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=K0clRFcF4d3Ei+rqMiSr/Wb2QKYV//zvUpRNWxPKi+A=; b=Z3Wo5SBlmMJYWsQ+PCHeTDoX6zC4/e50Dy/+sWZP0Xz5HteKLZriKbLBOE5YWu0KyRmdJt 8PxBmGDMg0KGbm1xdgQ1BHfmOCEqgd6IVsybIEPb5hgXLtbNs0nkvl8//KvzvWqrMfNTQX Pa2i0e1DrkSKZd9TGb5fn6D32/nDGKc= X-MC-Unique: dbdF8QBvM9iP3nyOlFw_lA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/36] virDomainSchedulerParse: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:08 +0100 Message-Id: <43fa4c60cb9fc8b0e459727c0667fe5ad80f21f1.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.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) X-ZM-MESSAGEID: 1639052359755100003 Content-Type: text/plain; charset="utf-8" Automatically free the 'ret' temporary bitmap and get rid of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 107d2a4f5d..c634e7dd41 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17977,34 +17977,30 @@ virDomainSchedulerParse(xmlNodePtr node, virProcessSchedPolicy *policy, int *priority) { - virBitmap *ret =3D NULL; + g_autoptr(virBitmap) ret =3D NULL; g_autofree char *tmp =3D NULL; if (!(tmp =3D virXMLPropString(node, attributeName))) { virReportError(VIR_ERR_XML_ERROR, _("Missing attribute '%s' in element '%s'"), attributeName, elementName); - goto error; + return NULL; } if (virBitmapParse(tmp, &ret, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto error; + return NULL; if (virBitmapIsAllClear(ret)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("'%s' scheduler bitmap '%s' is empty"), attributeName, tmp); - goto error; + return NULL; } if (virDomainSchedulerParseCommonAttrs(node, policy, priority) < 0) - goto error; - - return ret; + return NULL; - error: - virBitmapFree(ret); - return NULL; + return g_steal_pointer(&ret); } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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 From nobody Fri May 3 10:27:29 2024 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=V6kjPLpnzyulTddO19/T9t/zcFsnkgIUk5B2sJL6SBPAtMbsjEHN84MkW1mgAGF3zr8hEAVI7VpAL0ccSJg34obZcFZ+rc4tUA+ZVffrhPmRYcoGgWoJBdwHKhkPKB5PdMQZVF2jcNXZAfXo+o6qIxMiUI/kJm8j5NezIIz2l8A= 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=gmeHj6RSrB85C5XUiJYnjSXLyjiBChCpOz0y9xtil9I=; b=h0SjjPH+Q338OShEjE0QvkBXvXnInPNzVRfiLz7fWXxzBnU9CczbtpaqIkx1GgqOC4Ny3sek3LAC30RTh6SI/LFt095+Pxt6EOmARoskbvjrSxJR7oiIJdb9Zwhv1HafYWltzEeKeDfPRlRHJh4b8eJOoBvOZP1beGYKhRFWtws= 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 163905238865383.23256816409003; 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-103-Cya-bQUzNMaKnsJtzdyqng-1; Thu, 09 Dec 2021 07:19:46 -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 373C510151E1; Thu, 9 Dec 2021 12:19:40 +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 1D7C545D72; Thu, 9 Dec 2021 12:19:40 +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 E0CBD180B654; 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 1B9CJcGi013942 for ; Thu, 9 Dec 2021 07:19:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2621617DBA; Thu, 9 Dec 2021 12:19:38 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86E0B5E24E for ; Thu, 9 Dec 2021 12:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052387; 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=gmeHj6RSrB85C5XUiJYnjSXLyjiBChCpOz0y9xtil9I=; b=b+HNm7RzDrUsalV0T8ugTGM3bzjc2BX7wlra60G3XPG0PXK9KOlIjHZsjMH2wqEk6D1whH 1YuDDUMd2lH1hBZNLg/gtjtxJZxaLHvXwmlm86dpW7/hgTSLOKFy6S5b4A3Du6xq3QWuLj lcNhWUKULktWbDbVihdp4mAkfiq1/z8= X-MC-Unique: Cya-bQUzNMaKnsJtzdyqng-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/36] virDomainDriverGetIOThreadsConfig: Automatically free virBitmap Date: Thu, 9 Dec 2021 13:18:10 +0100 Message-Id: <44c5a841bb7aeb9e3b9abcdfd15bf90aded41638.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.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: 1639052390576100001 Content-Type: text/plain; charset="utf-8" Use g_autoptr for the temp bitmap. To achieve this the variable must be moved down to the appropriate scope. Signed-off-by: Peter Krempa --- src/hypervisor/domain_driver.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 31737b0f4a..2083f06287 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -592,8 +592,6 @@ virDomainDriverGetIOThreadsConfig(virDomainDef *targetD= ef, unsigned int bitmap_size) { virDomainIOThreadInfoPtr *info_ret =3D NULL; - virBitmap *bitmap =3D NULL; - virBitmap *cpumask =3D NULL; size_t i; int ret =3D -1; @@ -603,6 +601,8 @@ virDomainDriverGetIOThreadsConfig(virDomainDef *targetD= ef, info_ret =3D g_new0(virDomainIOThreadInfoPtr, targetDef->niothreadids); for (i =3D 0; i < targetDef->niothreadids; i++) { + g_autoptr(virBitmap) bitmap =3D NULL; + virBitmap *cpumask =3D NULL; info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); /* IOThread ID's are taken from the iothreadids list */ @@ -627,8 +627,6 @@ virDomainDriverGetIOThreadsConfig(virDomainDef *targetD= ef, if (virBitmapToData(cpumask, &info_ret[i]->cpumap, &info_ret[i]->cpumaplen) < 0) goto cleanup; - virBitmapFree(bitmap); - bitmap =3D NULL; } *info =3D g_steal_pointer(&info_ret); @@ -640,7 +638,6 @@ virDomainDriverGetIOThreadsConfig(virDomainDef *targetD= ef, virDomainIOThreadInfoFree(info_ret[i]); VIR_FREE(info_ret); } - virBitmapFree(bitmap); return ret; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052390; cv=none; d=zohomail.com; s=zohoarc; b=ANsQBYaAyHEdmdqEryaZqZEW8ICgMzenvRYndoB4sPu76DmGm4XibvYVDQBMx53Gn98d1hODQZzWLiA/kWzFTqqqDhkN8+72Y5KMVbqrEWQq+w8eVRN+AZUrTAHzFKjqvKUstkqlMbKbcodDzS0EplRGqXcmzaxe0OiTErFG03o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052390; 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=H8MqrVV0BvCWbAbE8VPnRXRqgt8Gi6nhC0hLzGxAT9U=; b=VbkKyMXc4lC0hk8B0RsZsyIx1wGeO/I8yjVVr74TNgmhy5XyFpjlQ+WD2+jxabgbP+bNwtm9Pj/WXHQBhZr7kkOkNN3OC+7o6+WZZ8Ehb/9sxfD9GEBALG3NgBu2Sohia2J76jy0yuqRR373rhFxdZhqCyFN86XAGyLQyD1lYNA= 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 163905239084472.36055861907846; Thu, 9 Dec 2021 04:19:50 -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-536-Ferk2508MS-77udlL4kOGA-1; Thu, 09 Dec 2021 07:19:46 -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 0B62510B746A; Thu, 9 Dec 2021 12:19:42 +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 C0C7976E3C; Thu, 9 Dec 2021 12:19:41 +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 744FB1806D1D; Thu, 9 Dec 2021 12:19:41 +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 1B9CJdOt013953 for ; Thu, 9 Dec 2021 07:19:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3503D17DBA; Thu, 9 Dec 2021 12:19:39 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86B385E24E for ; Thu, 9 Dec 2021 12:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052389; 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=H8MqrVV0BvCWbAbE8VPnRXRqgt8Gi6nhC0hLzGxAT9U=; b=Rt1eff/2G7jClc5X6wk6VnsT2te6rfAOaXtnQPgTKQT5d1WkA4OoaFVAMv2XibtBYfLGK+ D82kddOZgqb1zXSyg6dRw5MoODVtfIClJsvyLL9VPhDrrbjQ+79/7hVBuxDj4F2ToS3SOA oyncIXroUnBpX4RoYMWiIfyR0aVaoKU= X-MC-Unique: Ferk2508MS-77udlL4kOGA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/36] qemuDomainAssignMemorySlots: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:11 +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.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: 1639052393011100001 Content-Type: text/plain; charset="utf-8" Automatically free the 'slotmap' bitmap and get rid of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain_address.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index f4cddc6176..18fc34d049 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -3086,8 +3086,7 @@ qemuDomainReleaseMemoryDeviceSlot(virDomainObj *vm, static int qemuDomainAssignMemorySlots(virDomainDef *def) { - virBitmap *slotmap =3D NULL; - int ret =3D -1; + g_autoptr(virBitmap) slotmap =3D NULL; size_t i; if (!virDomainDefHasMemoryHotplug(def)) @@ -3103,7 +3102,7 @@ qemuDomainAssignMemorySlots(virDomainDef *def) case VIR_DOMAIN_MEMORY_MODEL_DIMM: case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: if (qemuAssignMemoryDeviceSlot(def->mems[i], slotmap) < 0) - goto cleanup; + return -1; break; case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM: @@ -3116,12 +3115,7 @@ qemuDomainAssignMemorySlots(virDomainDef *def) } } - ret =3D 0; - - cleanup: - virBitmapFree(slotmap); - return ret; - + return 0; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052393; cv=none; d=zohomail.com; s=zohoarc; b=d63DnSoG9vbFTeCQQRNMW/0h/YuFe44fUB5FYbrIHCoV5/3ZurLzH/yplImdsAxamoJ7oK1Ak3HVs2UF8XoA5t6lKoeI+/D6N9isM11JzP9GMEdSwo7C11CpP1zka53MYFE+5f0qAnr98HSScL3TZBWbuqcXiyw1d6uVzfkodJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052393; 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=09cDU+REe3L+ZmTsm8C34IowbU/e4WJOir6aSURf8Jw=; b=bWgeRbwoo4yDhZkgdWnOeUt795F/vhIqlFvbJXNNNPe02hvcVC0sa9cs9Shi6MRd0ZPhDtKjTBCx/hPQLTmoLTKaDnWbznfLDmDWwSISETGY9oGYUQXyE4y8m9iaEsLGFnZ4z0KChPbe/yYBCAmVEGbvlEr4m1GAxx5a6DH+0PI= 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 1639052393094208.41867061624077; Thu, 9 Dec 2021 04:19:53 -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-223-n_FH7mu2PJqRSYOOnKXePQ-1; Thu, 09 Dec 2021 07:19:48 -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 399ED2F4A; Thu, 9 Dec 2021 12:19:43 +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 1985B76E3C; Thu, 9 Dec 2021 12:19:43 +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 DFC8E4A708; Thu, 9 Dec 2021 12:19:42 +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 1B9CJeCQ013965 for ; Thu, 9 Dec 2021 07:19:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4D83817DBA; Thu, 9 Dec 2021 12:19:40 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8AC55E24E for ; Thu, 9 Dec 2021 12:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052392; 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=09cDU+REe3L+ZmTsm8C34IowbU/e4WJOir6aSURf8Jw=; b=SGaLPoGmHSLdZsBaAWlEVZ5naso5kQ9L8XskMW0mDiuuVeyS0bzijEI0r18jOBk3zcMZrN kOKl7xUXySdtQCh/a7F51cvtNNssrDbAAhAdF6Ti18hulsyEGBBUq6sOOWOmcV1NxcQoBS VYuPSHZryJ1TrmHDWT8QUkp0bl0ZiXE= X-MC-Unique: n_FH7mu2PJqRSYOOnKXePQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/36] qemu: driver: Automatically free temporary virBitmap-s Date: Thu, 9 Dec 2021 13:18:12 +0100 Message-Id: <10096daeff81b98c426b1ce2fb9f18f54e221731.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: 1639052393445100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 50 ++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8093b8f69b..79cfbc401c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1480,13 +1480,12 @@ qemuDomainHelperGetVcpus(virDomainObj *vm, if (cpumaps) { unsigned char *cpumap =3D VIR_GET_CPUMAP(cpumaps, maplen, ncpu= info); - virBitmap *map =3D NULL; + g_autoptr(virBitmap) map =3D NULL; if (!(map =3D virProcessGetAffinity(vcpupid))) return -1; virBitmapToDataBuf(map, cpumap, maplen); - virBitmapFree(map); } if (cpuwait) { @@ -4501,7 +4500,7 @@ qemuDomainPinVcpuLive(virDomainObj *vm, virQEMUDriver *driver, virBitmap *cpumap) { - virBitmap *tmpmap =3D NULL; + g_autoptr(virBitmap) tmpmap =3D NULL; virDomainVcpuDef *vcpuinfo; qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virCgroup) cgroup_vcpu =3D NULL; @@ -4547,8 +4546,7 @@ qemuDomainPinVcpuLive(virDomainObj *vm, } virBitmapFree(vcpuinfo->cpumask); - vcpuinfo->cpumask =3D tmpmap; - tmpmap =3D NULL; + vcpuinfo->cpumask =3D g_steal_pointer(&tmpmap); qemuDomainSaveStatus(vm); @@ -4566,7 +4564,6 @@ qemuDomainPinVcpuLive(virDomainObj *vm, ret =3D 0; cleanup: - virBitmapFree(tmpmap); virObjectEventStateQueue(driver->domainEventState, event); return ret; } @@ -4584,7 +4581,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, virDomainDef *def; virDomainDef *persistentDef; int ret =3D -1; - virBitmap *pcpumap =3D NULL; + g_autoptr(virBitmap) pcpumap =3D NULL; virDomainVcpuDef *vcpuinfo =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; @@ -4628,8 +4625,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, if (persistentDef) { virBitmapFree(vcpuinfo->cpumask); - vcpuinfo->cpumask =3D pcpumap; - pcpumap =3D NULL; + vcpuinfo->cpumask =3D g_steal_pointer(&pcpumap); ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->confi= gDir); goto endjob; @@ -4642,7 +4638,6 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); - virBitmapFree(pcpumap); return ret; } @@ -4708,7 +4703,7 @@ qemuDomainPinEmulator(virDomainPtr dom, virDomainDef *persistentDef; int ret =3D -1; qemuDomainObjPrivate *priv; - virBitmap *pcpumap =3D NULL; + g_autoptr(virBitmap) pcpumap =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; virObjectEvent *event =3D NULL; g_autofree char *str =3D NULL; @@ -4791,7 +4786,6 @@ qemuDomainPinEmulator(virDomainPtr dom, cleanup: virObjectEventStateQueue(driver->domainEventState, event); - virBitmapFree(pcpumap); virDomainObjEndAPI(&vm); return ret; } @@ -5017,7 +5011,7 @@ qemuDomainGetIOThreadsLive(virQEMUDriver *driver, info_ret =3D g_new0(virDomainIOThreadInfoPtr, niothreads); for (i =3D 0; i < niothreads; i++) { - virBitmap *map =3D NULL; + g_autoptr(virBitmap) map =3D NULL; info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); info_ret[i]->iothread_id =3D iothreads[i]->iothread_id; @@ -5025,12 +5019,8 @@ qemuDomainGetIOThreadsLive(virQEMUDriver *driver, if (!(map =3D virProcessGetAffinity(iothreads[i]->thread_id))) goto endjob; - if (virBitmapToData(map, &info_ret[i]->cpumap, - &info_ret[i]->cpumaplen) < 0) { - virBitmapFree(map); + if (virBitmapToData(map, &info_ret[i]->cpumap, &info_ret[i]->cpuma= plen) < 0) goto endjob; - } - virBitmapFree(map); } *info =3D g_steal_pointer(&info_ret); @@ -5100,7 +5090,7 @@ qemuDomainPinIOThread(virDomainPtr dom, virDomainObj *vm; virDomainDef *def; virDomainDef *persistentDef; - virBitmap *pcpumap =3D NULL; + g_autoptr(virBitmap) pcpumap =3D NULL; qemuDomainObjPrivate *priv; g_autoptr(virCgroup) cgroup_iothread =3D NULL; virObjectEvent *event =3D NULL; @@ -5214,7 +5204,6 @@ qemuDomainPinIOThread(virDomainPtr dom, cleanup: virObjectEventStateQueue(driver->domainEventState, event); - virBitmapFree(pcpumap); virDomainObjEndAPI(&vm); return ret; } @@ -8846,7 +8835,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom, int ret =3D -1; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; qemuDomainObjPrivate *priv; - virBitmap *nodeset =3D NULL; + g_autoptr(virBitmap) nodeset =3D NULL; virDomainNumatuneMemMode config_mode; int mode =3D -1; @@ -8953,7 +8942,6 @@ qemuDomainSetNumaParameters(virDomainPtr dom, qemuDomainObjEndJob(driver, vm); cleanup: - virBitmapFree(nodeset); virDomainObjEndAPI(&vm); return ret; } @@ -16579,7 +16567,7 @@ qemuDomainGetCPUStats(virDomainPtr domain, virDomainObj *vm =3D NULL; int ret =3D -1; qemuDomainObjPrivate *priv; - virBitmap *guestvcpus =3D NULL; + g_autoptr(virBitmap) guestvcpus =3D NULL; virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); @@ -16611,7 +16599,6 @@ qemuDomainGetCPUStats(virDomainPtr domain, ret =3D virCgroupGetPercpuStats(priv->cgroup, params, nparams, start_cpu, ncpus, guestvcpus); cleanup: - virBitmapFree(guestvcpus); virDomainObjEndAPI(&vm); return ret; } @@ -19385,9 +19372,9 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPtr = *params, virTypedParameterPtr par =3D NULL; int npar =3D 0; int maxpar =3D 0; - virBitmap *vcpus =3D virBitmapNew(QEMU_GUEST_VCPU_MAX_ID); - virBitmap *online =3D virBitmapNew(QEMU_GUEST_VCPU_MAX_ID); - virBitmap *offlinable =3D virBitmapNew(QEMU_GUEST_VCPU_MAX_ID); + g_autoptr(virBitmap) vcpus =3D virBitmapNew(QEMU_GUEST_VCPU_MAX_ID); + g_autoptr(virBitmap) online =3D virBitmapNew(QEMU_GUEST_VCPU_MAX_ID); + g_autoptr(virBitmap) offlinable =3D virBitmapNew(QEMU_GUEST_VCPU_MAX_I= D); g_autofree char *tmp =3D NULL; size_t i; int ret =3D -1; @@ -19424,9 +19411,6 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPtr = *params, ret =3D 0; cleanup: - virBitmapFree(vcpus); - virBitmapFree(online); - virBitmapFree(offlinable); virTypedParamsFree(par, npar); return ret; } @@ -19489,7 +19473,7 @@ qemuDomainSetGuestVcpus(virDomainPtr dom, { virQEMUDriver *driver =3D dom->conn->privateData; virDomainObj *vm =3D NULL; - virBitmap *map =3D NULL; + g_autoptr(virBitmap) map =3D NULL; qemuAgentCPUInfo *info =3D NULL; qemuAgent *agent; int ninfo =3D 0; @@ -19562,7 +19546,6 @@ qemuDomainSetGuestVcpus(virDomainPtr dom, cleanup: VIR_FREE(info); - virBitmapFree(map); virDomainObjEndAPI(&vm); return ret; } @@ -19578,7 +19561,7 @@ qemuDomainSetVcpu(virDomainPtr dom, virDomainObj *vm =3D NULL; virDomainDef *def =3D NULL; virDomainDef *persistentDef =3D NULL; - virBitmap *map =3D NULL; + g_autoptr(virBitmap) map =3D NULL; ssize_t lastvcpu; int ret =3D -1; @@ -19635,7 +19618,6 @@ qemuDomainSetVcpu(virDomainPtr dom, qemuDomainObjEndJob(driver, vm); cleanup: - virBitmapFree(map); virDomainObjEndAPI(&vm); return ret; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052396; cv=none; d=zohomail.com; s=zohoarc; b=Tyj2kNUlaIQmIGsnO7DrNh/iiV88hFZPddXb+MRClNMqWs36DHralB7Sljfkrzb6ds31DK2cdvC0E4BrzPa/luzms3mxzIQ948p4EQoZWkT4qXa2O11jNRHawQnlUkNPwJvrLB8muiTe1Mkv/WM+mayb0rSXMYKOEOe7TNhscxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052396; 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=KZaVBOWqypHTTgcNQn9HCUllj10neIVxiUNhNaeDyMs=; b=Ui21/A9Bkskv6FmBpvSw0Ee/07ifKb9BpTFHJw/8xcgfnzjP0QwS/0+xKF9mNgXCyUGTDP9J+3VeFKBHISmcD2v2+xrkIDG1wPKsV+saetW7H+tT58QX76EjSf5rs8Ov//29nLa1BaKS1rW9aGXfLqZyK8Hdn0YvbnDRGiIpfxQ= 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 1639052396575510.04649811836; Thu, 9 Dec 2021 04:19:56 -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-520-zNGJ7vT0P6CPCG70BUzPyQ-1; Thu, 09 Dec 2021 07:19:52 -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 98F3F193F588; Thu, 9 Dec 2021 12:19:44 +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 38D0C45D72; Thu, 9 Dec 2021 12:19:44 +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 0EC4F1806D2D; Thu, 9 Dec 2021 12:19:44 +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 1B9CJfOr013970 for ; Thu, 9 Dec 2021 07:19:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5CE2C5ED32; Thu, 9 Dec 2021 12:19:41 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id B30195ED2B for ; Thu, 9 Dec 2021 12:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052395; 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=KZaVBOWqypHTTgcNQn9HCUllj10neIVxiUNhNaeDyMs=; b=N8TrVMzr+a51z5+1Ph7T7MJWFa2xg+gFrriWZMl5OEFTteMSKbKDdEEPuPobbBxOlabea2 VVWtj8luBT3ouPOsKSbBOlhm0kRbwKVl27D/rQJ4qW3/Jt39u2TvfdQ8z+Nzan6uyDCQNE c0HxiBSUVXPAhtff1JT0u3CJ7EBS8NQ= X-MC-Unique: zNGJ7vT0P6CPCG70BUzPyQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/36] qemuDomainSelectHotplugVcpuEntities: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:13 +0100 Message-Id: <596f77014f332de51a928b2452c32dc103876c1e.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.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: 1639052398222100007 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for the 'ret' bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2e1d18c633..f307420ac1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6473,7 +6473,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def, unsigned int nvcpus, bool *enable) { - virBitmap *ret =3D NULL; + g_autoptr(virBitmap) ret =3D NULL; virDomainVcpuDef *vcpu; qemuDomainVcpuPrivate *vcpupriv; unsigned int maxvcpus =3D virDomainDefGetVcpusMax(def); @@ -6501,7 +6501,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("target vm vcpu granularity does not allo= w the " "desired vcpu count")); - goto error; + return NULL; } ignore_value(virBitmapSetBit(ret, i)); @@ -6528,7 +6528,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("target vm vcpu granularity does not allo= w the " "desired vcpu count")); - goto error; + return NULL; } ignore_value(virBitmapSetBit(ret, i)); @@ -6539,14 +6539,10 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *d= ef, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("failed to find appropriate hotpluggable vcpus to= " "reach the desired target vcpu count")); - goto error; + return NULL; } - return ret; - - error: - virBitmapFree(ret); - return NULL; + return g_steal_pointer(&ret); } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052395; cv=none; d=zohomail.com; s=zohoarc; b=gH7gKjvFuGoJfuICXAbz5JGoX/DrE40jvgzsEpmIEJKwXLVoH9roxvdcOz4Ifp7fObfItweDYIuqUoEocTEHLBgoJyVWWdxC7rQ9bdSjeoYmk7zswW0GqlSsZCZw6cxSomahVgrbkokLjZ4HlJ+lSwCIZBscPyfBJT6bvNY+1zY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052395; 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=Q4mxLxsWj/uKAAd4kt/rEPdCmf5OJFRaf3Jdt3IPum0=; b=FjuoO0rNXZ54iU0WpLzUaespW/D62nlbM+ehjpb6Ku/bJx6Cmry3c3X1xgDL2B+JBIqx0ej3AZWss/dcA6bA2jKz+slcTwbXX80099Gydth6Q8x2Qk4SNWZwIQoZNyo6clvY5WE8Rv4uUCXD4Ft18DembmYQq3Jr1irbuWZ4IQ8= 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 1639052395434584.7904212997877; Thu, 9 Dec 2021 04:19:55 -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-142-0RCmsp7TPWWEd6HgmLmXJw-1; Thu, 09 Dec 2021 07:19:51 -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 C9F721575A; Thu, 9 Dec 2021 12:19:45 +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 A7D2967846; Thu, 9 Dec 2021 12:19:45 +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 756281806D2E; Thu, 9 Dec 2021 12:19:45 +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 1B9CJgQC013976 for ; Thu, 9 Dec 2021 07:19:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 705B35ED32; Thu, 9 Dec 2021 12:19:42 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCA585ED2B for ; Thu, 9 Dec 2021 12:19:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052394; 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=Q4mxLxsWj/uKAAd4kt/rEPdCmf5OJFRaf3Jdt3IPum0=; b=LosAUbaf3tMLuXIR+Mw/9bXWdJrAfdX0GxZcOjzODzjMUYO5SjTFyG9xMRi6WWZOAMOINC L3tB3Xy/pRZn/KWdtgkNqrpPSO0nLCBPLtrtyC6e6TIZ3c/bIAp3m7LmbVQUEVw04AgGD2 ByIzOalFa4R5lxNWlO5fI3quFRW4wRw= X-MC-Unique: 0RCmsp7TPWWEd6HgmLmXJw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/36] qemuDomainSetVcpusInternal: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:14 +0100 Message-Id: <9f0adb966a87c115f0973c5c38dad18b0e051ad1.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.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: 1639052396044100003 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f307420ac1..b4c8536b47 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6665,16 +6665,15 @@ qemuDomainSetVcpusInternal(virQEMUDriver *driver, bool hotpluggable) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - virBitmap *vcpumap =3D NULL; + g_autoptr(virBitmap) vcpumap =3D NULL; bool enable; - int ret =3D -1; if (def && nvcpus > virDomainDefGetVcpusMax(def)) { virReportError(VIR_ERR_INVALID_ARG, _("requested vcpus is greater than max allowable" " vcpus for the live domain: %u > %u"), nvcpus, virDomainDefGetVcpusMax(def)); - goto cleanup; + return -1; } if (persistentDef && nvcpus > virDomainDefGetVcpusMax(persistentDef)) { @@ -6682,30 +6681,26 @@ qemuDomainSetVcpusInternal(virQEMUDriver *driver, _("requested vcpus is greater than max allowable" " vcpus for the persistent domain: %u > %u"), nvcpus, virDomainDefGetVcpusMax(persistentDef)); - goto cleanup; + return -1; } if (def) { if (!(vcpumap =3D qemuDomainSelectHotplugVcpuEntities(vm->def, nvc= pus, &enable))) - goto cleanup; + return -1; if (qemuDomainSetVcpusLive(driver, cfg, vm, vcpumap, enable) < 0) - goto cleanup; + return -1; } if (persistentDef) { qemuDomainSetVcpusConfig(persistentDef, nvcpus, hotpluggable); if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) - goto cleanup; + return -1; } - ret =3D 0; - - cleanup: - virBitmapFree(vcpumap); - return ret; + return 0; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052394; cv=none; d=zohomail.com; s=zohoarc; b=NkG6XgBMea0RefqrZge39lh0OT4V9syngrnJW2QZF7PxqSOO/F80eJ7XTUoIplPkGGWltS3Fja4CT4bE1VGLg6BN/HVl4x0cRa/nknsKY1G0ONysaoWGWRu9Ko2lZ5q2avWp3gF/afG+GXNJeqaGIT0+2o2vwnmDF/+NevyXplg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052394; 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=c1QUHvUqM1u2BCXc+RRYNBFaZFd7vJlvyDD7xv1orU8=; b=CCC6rnO/H1UGrJOogP7Ypn0PR/uKBO3RtzaHHYL1gXtDNcZfItYuMf51KE3JceHbfvSk4hqMelCk48t/DSq0hbNRgRjIDVUqcAX8ztaXMjIw1a3urdlnbFuNASYi1FOTdXf/KC8FyknG4yBP4OacQcidM4B5lzj01E/+kW6Ne6w= 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 163905239467215.782221463294945; Thu, 9 Dec 2021 04:19:54 -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-486-L2m-z5JdOc--FVoMZYhwJw-1; Thu, 09 Dec 2021 07:19:50 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B485415758; Thu, 9 Dec 2021 12:19:45 +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 8E03A5BE07; Thu, 9 Dec 2021 12:19:45 +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 5C8374A70A; Thu, 9 Dec 2021 12:19:45 +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 1B9CJhmj013995 for ; Thu, 9 Dec 2021 07:19:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7FED85ED3B; Thu, 9 Dec 2021 12:19:43 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id D583E5ED32 for ; Thu, 9 Dec 2021 12:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052393; 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=c1QUHvUqM1u2BCXc+RRYNBFaZFd7vJlvyDD7xv1orU8=; b=MxspvmhtebFNHm9F5oK0PG9n/AFobZgd7buyHlffpzf47ZyU5CPtXQE/s2RkuWlxfB3AAl Fa3UtDT3F8Kx/HZaxDrlx1kZ8I9oHLC1U0C9WDERs825RlVcBCebLczayOO5mJmOmJLUxx tMk4sGwKNJKwpHT3I7FMnhuveUyLq8w= X-MC-Unique: L2m-z5JdOc--FVoMZYhwJw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/36] qemuDomainSetVcpuInternal: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:15 +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.15 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: 1639052395812100001 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index b4c8536b47..32728a196a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6845,19 +6845,18 @@ qemuDomainSetVcpuInternal(virQEMUDriver *driver, bool state) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - virBitmap *livevcpus =3D NULL; - int ret =3D -1; + g_autoptr(virBitmap) livevcpus =3D NULL; if (def) { if (!qemuDomainSupportsNewVcpuHotplug(vm)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("this qemu version does not support specific " "vCPU hotplug")); - goto cleanup; + return -1; } if (!(livevcpus =3D qemuDomainFilterHotplugVcpuEntities(def, map, = state))) - goto cleanup; + return -1; /* Make sure that only one hotpluggable entity is selected. * qemuDomainSetVcpusLive allows setting more at once but error @@ -6866,31 +6865,27 @@ qemuDomainSetVcpuInternal(virQEMUDriver *driver, if (virBitmapCountBits(livevcpus) !=3D 1) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("only one hotpluggable entity can be selected= ")); - goto cleanup; + return -1; } } if (persistentDef) { if (qemuDomainVcpuValidateConfig(persistentDef, map) < 0) - goto cleanup; + return -1; } if (livevcpus && qemuDomainSetVcpusLive(driver, cfg, vm, livevcpus, state) < 0) - goto cleanup; + return -1; if (persistentDef) { qemuDomainSetVcpuConfig(persistentDef, map, state); if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) - goto cleanup; + return -1; } - ret =3D 0; - - cleanup: - virBitmapFree(livevcpus); - return ret; + return 0; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052398; cv=none; d=zohomail.com; s=zohoarc; b=PTP+fQv1MIzHEQSB4MdWmo4IgZXU88GZC5Z72+UdXJQmKYmnuTxy7Wby25ZPR2jw5xFr7modZvDYOjGTXzc3WIKcoqtbOKu5Z7D5JKUcNzMffRJG97A+JuGXeNif6nuZgw+q8sjp6TtnGsIA5tfP8PMGs+TqIRWvgZOFO8RbeMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052398; 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=G9j5rL17Za0ERtPHvtn1fsjkwxcBRPjaLs1YVfK01Ug=; b=J72cZwjWsSgx8cx00jJF3JSYS7dCs5pn2m2OwNI6ZPZUlmD7aQX229Z8qlzK79ZnLaum6gXF36aTraA41bmStlHMJbue9C7GNNCWeH2mZ9OyYbjEgBZj7s0+qGVyC0/0QIw/Fd4Pe6wV6rkWR/yJs4xTfuyFuf4HChnLSLVuOk8= 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 1639052398304462.0246744188403; Thu, 9 Dec 2021 04:19:58 -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-584-KqWicwiMNAyFrcBXJHvoLg-1; Thu, 09 Dec 2021 07:19:54 -0500 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 2D06481EE74; Thu, 9 Dec 2021 12:19:48 +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 0F2EA17DBA; Thu, 9 Dec 2021 12:19:48 +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 D628F1805302; Thu, 9 Dec 2021 12:19:47 +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 1B9CJi5c014006 for ; Thu, 9 Dec 2021 07:19:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9159B5ED32; Thu, 9 Dec 2021 12:19:44 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDB005ED36 for ; Thu, 9 Dec 2021 12:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052397; 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=G9j5rL17Za0ERtPHvtn1fsjkwxcBRPjaLs1YVfK01Ug=; b=R7V0wIxN6mp22F5IE+RTeV9EAdwSrwAspTX3SxricskJzQT2ykZnPxrCBUCW0SkLiZoRtH PR5PZiGVxggwnScCfjXEN3VVjL1QHCmGesYXbQRAkL5+Hgu0w98H3S9ZwVNLiLeRKeskDf vMifDpSUJv/zr7OB6OV8QxwvK6R12ps= X-MC-Unique: KqWicwiMNAyFrcBXJHvoLg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/36] qemuProcessValidateHotpluggableVcpus: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:16 +0100 Message-Id: <29c5b008d3ce98462ae14e72036c3fa99ef8cd7c.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.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) X-ZM-MESSAGEID: 1639052400516100001 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_process.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6b83a571b9..804205131a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5954,8 +5954,7 @@ qemuProcessValidateHotpluggableVcpus(virDomainDef *de= f) unsigned int maxvcpus =3D virDomainDefGetVcpusMax(def); size_t i =3D 0; size_t j; - virBitmap *ordermap =3D virBitmapNew(maxvcpus + 1); - int ret =3D -1; + g_autoptr(virBitmap) ordermap =3D virBitmapNew(maxvcpus + 1); /* validate: * - all hotpluggable entities to be hotplugged have the correct data @@ -5974,14 +5973,14 @@ qemuProcessValidateHotpluggableVcpus(virDomainDef *= def) if (virBitmapIsBitSet(ordermap, vcpu->order)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("duplicate vcpu order '%u'"), vcpu->order= ); - goto cleanup; + return -1; } if (virBitmapSetBit(ordermap, vcpu->order)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vcpu order '%u' exceeds vcpu count"), vcpu->order); - goto cleanup; + return -1; } } @@ -5993,7 +5992,7 @@ qemuProcessValidateHotpluggableVcpus(virDomainDef *de= f) virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vcpus '%zu' and '%zu' are in the same ho= tplug " "group but differ in configuration"), i, = j); - goto cleanup; + return -1; } } @@ -6003,15 +6002,12 @@ qemuProcessValidateHotpluggableVcpus(virDomainDef *= def) !vcpupriv->type) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vcpu '%zu' is missing hotplug data"), i); - goto cleanup; + return -1; } } } - ret =3D 0; - cleanup: - virBitmapFree(ordermap); - return ret; + return 0; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052482; cv=none; d=zohomail.com; s=zohoarc; b=KAyvUD88HNtSVRf2Qu+BA0Ru6xX2hpRxmw/On5hJHjiTkEc8l/4xh5QkO8yzEMROnrwaHoeCknfQD+6Myu9tlCgz5RgQKG8JGr3DbWqFiblA17EeY0ofejiY4UPwRcmtRuOTXhvphvrIQW/78Rlw5YEhkyvm4WaE+8lbgcLjYiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052482; 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=YBUgZ2qds2lZ/Nw6od91d9NxvzYWnINer4cQdhtC7Zs=; b=J4CEPqHMRU7+DzmD0cePlfDKC5Y1snbBMmktNVVRKi1pka45OiZaHjs8wRQNLzOEIo4if6zFLjDBQav/amgn4gI2S1ndDRb8dOTDqRcOnNdpDWgzZHcuMd6gms57S54NXIJBJEOLBQMt6HvlfU3PHCpYq1f2QoEKUEuHuM2PXuY= 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 1639052482673577.0996202395648; Thu, 9 Dec 2021 04:21:22 -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-434-Pqznd1dCMuWp8_PKwq5v6g-1; Thu, 09 Dec 2021 07:19:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A53E7193F57A; Thu, 9 Dec 2021 12:19:50 +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 8B915694C0; Thu, 9 Dec 2021 12:19:50 +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 59E851803390; Thu, 9 Dec 2021 12:19:50 +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 1B9CJjOI014015 for ; Thu, 9 Dec 2021 07:19:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id A2DEF5ED2A; Thu, 9 Dec 2021 12:19:45 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 001E05ED32 for ; Thu, 9 Dec 2021 12:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052481; 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=YBUgZ2qds2lZ/Nw6od91d9NxvzYWnINer4cQdhtC7Zs=; b=i+0KblZjqBaMZFZR0dsl6ToI15WNuY27XwZd4RQ+tPT79WCAe6b0dfl10pKZKNPKyZLm59 rSKjAO6zCxPLF57rOs6+cT7NdSTCOoNcg2aMm2JVeXcE4PufqTHdw3GMKZ8nLVVcWpieG2 3pdzJLqnj6jH8Yu8jB5LD0nt/6q7rjc= X-MC-Unique: Pqznd1dCMuWp8_PKwq5v6g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/36] qemuSnapshotCreateInactiveExternal: Automatically free temporary variables Date: Thu, 9 Dec 2021 13:18:17 +0100 Message-Id: <1e951bd82f4e06ff321170239f7c1bf1462d4add.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.13 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: 1639052483798100001 Content-Type: text/plain; charset="utf-8" Automatically free 'cmd' and 'created' by moving them to the appropriate scopes. Signed-off-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 1a32b15f51..9a5d3e60aa 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -181,23 +181,21 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *dri= ver, size_t i; virDomainSnapshotDiskDef *snapdisk; virDomainDiskDef *defdisk; - virCommand *cmd =3D NULL; const char *qemuImgPath; - virBitmap *created =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); int ret =3D -1; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); + g_autoptr(virBitmap) created =3D virBitmapNew(snapdef->ndisks); if (!(qemuImgPath =3D qemuFindQemuImgBinary(driver))) goto cleanup; - created =3D virBitmapNew(snapdef->ndisks); - /* If reuse is true, then qemuSnapshotPrepare already * ensured that the new files exist, and it was up to the user to * create them correctly. */ for (i =3D 0; i < snapdef->ndisks && !reuse; i++) { + g_autoptr(virCommand) cmd =3D NULL; snapdisk =3D &(snapdef->disks[i]); defdisk =3D vm->def->disks[i]; if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) @@ -234,9 +232,6 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *drive= r, if (virCommandRun(cmd, NULL) < 0) goto cleanup; - - virCommandFree(cmd); - cmd =3D NULL; } /* update disk definitions */ @@ -272,8 +267,6 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *drive= r, ret =3D 0; cleanup: - virCommandFree(cmd); - /* unlink images if creation has failed */ if (ret < 0 && created) { ssize_t bit =3D -1; @@ -284,7 +277,6 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *drive= r, snapdisk->src->path); } } - virBitmapFree(created); return ret; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052468; cv=none; d=zohomail.com; s=zohoarc; b=RSJtAut/Zkz8+CkkrqnvZeReXKqlmGTKdpvkNz2n6pWyPOySd+Axshw+7cP9UzDwCzpO3WbhQF4eUNnNTkR+ikZTphoBpdyFVZHAwRosCBvYbLVt8hr3lTs3xGRCTsuVdagovU6sh/+V6rD3EH5is04YDxCyGufzyrajhm+489s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052468; 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=D6dW9WPdJZwYMa6ytKSilw50B5ERsfd8AX2KskcsEoI=; b=RDuXMM7zjyN6C8gOkes5mXmFTV7ZMumxrAQa8jXe+XmERIyMWdhU82IiAhMWBpwCLjjQHXo8z3YDzbEi5u5WauuJBHy6tFDzLpH7AAp0EJueORzpvt4Do7WEiBlVH1XfiEG3EM5+tX6HYkbJKjlEfNtcKnwiBUJP/RU/03oS0PY= 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 1639052468441862.8396358223987; Thu, 9 Dec 2021 04:21:08 -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-123-zk0UPAAIM0alyW_LqDIXDg-1; Thu, 09 Dec 2021 07:19:58 -0500 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 14F3D81EE67; Thu, 9 Dec 2021 12:19:53 +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 E94A31972E; Thu, 9 Dec 2021 12:19:52 +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 AC8BE1802FE8; Thu, 9 Dec 2021 12:19:52 +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 1B9CJoQm014044 for ; Thu, 9 Dec 2021 07:19:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id DB46C17DBA; Thu, 9 Dec 2021 12:19:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 498205ED37 for ; Thu, 9 Dec 2021 12:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052467; 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=D6dW9WPdJZwYMa6ytKSilw50B5ERsfd8AX2KskcsEoI=; b=jP6XjuLq5L7wts1PJsbWuSfHEUtJ2Dm2PuVQGN88u+HpaGSdFiOqBYxRBbv4QTM6icsj6i Z5LShxwHGfXapaDDcFsIISlVxtLICvdCECJQTuRbdjhemAxPDmt4SpEbSDN5N+9u9xy9QY LN/0AKToXs8n8f0jQeDm+65ayL9+K+M= X-MC-Unique: zk0UPAAIM0alyW_LqDIXDg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/36] virHostCPUCountThreadSiblings: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:18 +0100 Message-Id: <70b2b96aecd8d3f0e0f6bdfb309198fa5bf78a72.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.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) X-ZM-MESSAGEID: 1639052470056100001 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa --- src/util/virhostcpu.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 67b6910626..ad75eb5843 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -271,17 +271,12 @@ virHostCPUGetSiblingsList(unsigned int cpu) static unsigned long virHostCPUCountThreadSiblings(unsigned int cpu) { - virBitmap *siblings_map; - unsigned long ret =3D 0; + g_autoptr(virBitmap) siblings_map =3D NULL; if (!(siblings_map =3D virHostCPUGetSiblingsList(cpu))) - goto cleanup; - - ret =3D virBitmapCountBits(siblings_map); + return 0; - cleanup: - virBitmapFree(siblings_map); - return ret; + return virBitmapCountBits(siblings_map); } /* parses a node entry, returning number of processors in the node and --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052426; cv=none; d=zohomail.com; s=zohoarc; b=kdyjMFk+iRkKkh/EYoIbQFVACZSrkCtAvFJG25PEJxIztluo+FUY5PA58A2H6mDho0wDUfBc4CI8lXhvprnbXVOJuIY+BoIbNm0rk2S/k12j0TdphXFK+G8ALJ0BYO4ahu4vu0MewyN9GY231LnJeLa6EDbRECDvlQGrDAyinIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052426; 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=BVNeOB2ZK0fe2pzliRR4V7WvPzrBu5rfmRdpBVgpeWw=; b=ABVKj2qD6yePPSZBPz+DMwj/ffjwYItlzQvaF/rg7IGmQwtvqop+hROfh6IcgeHUyvc28FzB88kzaXNNpweJdbmO46RjojCUNEozqjoL+sRx6quqBM3Oxl9JwkRNGUAuxoH+epUBy1geLcgGigd4/phMDlcnBa298gaW4kn1cM4= 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 1639052426099602.0648775485234; Thu, 9 Dec 2021 04:20:26 -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-492-K7_hw903NNihF3zUXrOIgA-1; Thu, 09 Dec 2021 07:20:23 -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 8B569835E24; Thu, 9 Dec 2021 12:20:18 +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 0341C60657; Thu, 9 Dec 2021 12:20:18 +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 1EA821802FE9; Thu, 9 Dec 2021 12:20:17 +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 1B9CKEl7014494 for ; Thu, 9 Dec 2021 07:20:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id ED71217DBA; Thu, 9 Dec 2021 12:20:14 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F3255ED39 for ; Thu, 9 Dec 2021 12:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052425; 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=BVNeOB2ZK0fe2pzliRR4V7WvPzrBu5rfmRdpBVgpeWw=; b=gJcMOWhbHnBEiikWAltmbnljOeDD80kj8TzakpRRM2cK+J5OjhNBZYb15PpXwJa5jWka8X JjCC4yHRL6ayZTGC3NcICb7mOQpXvQqxL9PYQXB9olNFPStrlyTlbzSM5WOR3bIEQh69zx RrdKMVpP7mPlP5bx3fe0jeIfHxbozjE= X-MC-Unique: K7_hw903NNihF3zUXrOIgA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/36] virHostCPUHasValidSubcoreConfiguration: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:19 +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: 1639052427766100001 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa --- src/util/virhostcpu.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index ad75eb5843..a8d8b34a39 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -450,31 +450,25 @@ virHostCPUParseNode(const char *node, static bool virHostCPUHasValidSubcoreConfiguration(int threads_per_subcore) { - virBitmap *online_cpus =3D NULL; + g_autoptr(virBitmap) online_cpus =3D NULL; int cpu =3D -1; - bool ret =3D false; /* No point in checking if subcores are not in use */ if (threads_per_subcore <=3D 0) - goto cleanup; + return false; if (!(online_cpus =3D virHostCPUGetOnlineBitmap())) - goto cleanup; + return false; while ((cpu =3D virBitmapNextSetBit(online_cpus, cpu)) >=3D 0) { /* A single online secondary thread is enough to * make the configuration invalid */ if (cpu % threads_per_subcore !=3D 0) - goto cleanup; + return false; } - ret =3D true; - - cleanup: - virBitmapFree(online_cpus); - - return ret; + return true; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052432; cv=none; d=zohomail.com; s=zohoarc; b=iEp60gXOealr0Rl5mBSw5tCvMYWK2zalQoVdHUseOj4yzx2NpDrLV7yhgChw12Pq4Pw1DedUW5QwkHGYnbzlXDKnNGuDFau1OvLnMl3723EH3Sr9si5sxq7/9o6IqJdn9+5RgzolhYGmvUCbL0Gd1xqcuzU7zYvPuvO472Rgfjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052432; 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=HJ6B5Iv2V22HLDMImG1g+H/Lku/7TiG+BqKm21zkKcQ=; b=C2G/0x1ugLY8n6m4N9hkPC0sePkSXe1xayUnYvknNOgsIGp2vk5RwUbG382MhQrtfyJISh3QP6triHYjrTej1aneDKq8HJy8pdpXFXDdCl9jLBLlKuBLmYErvL/yWY+Fl0CjRQGzr9QhW6In9Zo9D42Z697uw3C/7zMv8UYmtKk= 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 1639052432535226.6079881591046; Thu, 9 Dec 2021 04:20:32 -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-525-BmuFh-76MbeyEGoTXb4qXw-1; Thu, 09 Dec 2021 07:20:29 -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 946BF83DBD2; Thu, 9 Dec 2021 12:20:24 +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 7A69C45D61; Thu, 9 Dec 2021 12:20:24 +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 4F0AD4A70A; Thu, 9 Dec 2021 12:20:24 +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 1B9CKGe8014501 for ; Thu, 9 Dec 2021 07:20:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 13EDD17DBA; Thu, 9 Dec 2021 12:20:16 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 675B75E26C for ; Thu, 9 Dec 2021 12:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052431; 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=HJ6B5Iv2V22HLDMImG1g+H/Lku/7TiG+BqKm21zkKcQ=; b=XfAUpSfSG3v4fbxy2n+bTYd6h6Tv+BP6jrf6TVjbQadYl8+AfxdeWznylzvjYA7Huxfyn9 bMI1aOmL0klHFjbTI8uduXceV4BSBRUKxmJXNl/LLe2AayFLfFs6jw4e0QlKAhoqHsKCIb o30sJ/r9pM9kf0foTxms7jegAB6m7T4= X-MC-Unique: BmuFh-76MbeyEGoTXb4qXw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/36] virHostCPUParseNode: Use automatic memory freeing for virBitmap Date: Thu, 9 Dec 2021 13:18:20 +0100 Message-Id: <204938d7790dbc3d5e4cb7e2cd7c7187803cea13.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.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: 1639052433350100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virhostcpu.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index a8d8b34a39..1920184f61 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -300,10 +300,10 @@ virHostCPUParseNode(const char *node, int processors =3D 0; g_autoptr(DIR) cpudir =3D NULL; struct dirent *cpudirent =3D NULL; - virBitmap *node_cpus_map =3D NULL; - virBitmap *sockets_map =3D NULL; + g_autoptr(virBitmap) sockets_map =3D virBitmapNew(0); virBitmap **cores_maps =3D NULL; int npresent_cpus =3D virBitmapSize(present_cpus_map); + g_autoptr(virBitmap) node_cpus_map =3D virBitmapNew(npresent_cpus); unsigned int sock_max =3D 0; unsigned int sock; unsigned int core; @@ -319,12 +319,6 @@ virHostCPUParseNode(const char *node, if (virDirOpen(&cpudir, node) < 0) goto cleanup; - /* Keep track of the CPUs that belong to the current node */ - node_cpus_map =3D virBitmapNew(npresent_cpus); - - /* enumerate sockets in the node */ - sockets_map =3D virBitmapNew(0); - while ((direrr =3D virDirRead(cpudir, &cpudirent, node)) > 0) { if (sscanf(cpudirent->d_name, "cpu%u", &cpu) !=3D 1) continue; @@ -437,8 +431,6 @@ virHostCPUParseNode(const char *node, for (i =3D 0; i < sock_max; i++) virBitmapFree(cores_maps[i]); VIR_FREE(cores_maps); - virBitmapFree(sockets_map); - virBitmapFree(node_cpus_map); return ret; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052429; cv=none; d=zohomail.com; s=zohoarc; b=AB6TTQYf3AVWwdTaidIdjjW9aOx2a+n9I55gPGQpAXEWrySh/Z2PFDjDAZLsZX5/4yJGENTxtDVFGEj7dLyAZtZjdoQ41c8SOrxOQnAqmrSfT/upsoiIpTvJbofRm86AswiCWYqET58lKviJmpglAAGHW4QI2eER6SYxqOCIcFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052429; 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=yf+Q82zp4YGCqV5qyZVEqlAq8a9CnNfFXH/xHTbbB2Q=; b=K/taeCsEY6ylpy+hXmb9yHKcLF/8UJpu+YFj64teF+x1n+vY9b8MvdydeC9lOP/veAYUUDfeeuYBgssBPXbcnNxtihbQeQYCkfhnIrlQZ4Ln3Wo8k4TEyI6t9cBpBgxqwdUcK4jDoYrLwPiMulch37/xBWmqppQ8QTDcV06LxCk= 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 1639052429370861.0120642035017; Thu, 9 Dec 2021 04:20:29 -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-546-8V-4GagnOCi9xDi7gw8v0g-1; Thu, 09 Dec 2021 07:20:25 -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 6BC881966322; Thu, 9 Dec 2021 12:20:20 +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 5258445D74; Thu, 9 Dec 2021 12:20:20 +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 0F1401802FEA; Thu, 9 Dec 2021 12:20:20 +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 1B9CKHrL014527 for ; Thu, 9 Dec 2021 07:20:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 28F0F17DBA; Thu, 9 Dec 2021 12:20:17 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 886655E26C for ; Thu, 9 Dec 2021 12:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052428; 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=yf+Q82zp4YGCqV5qyZVEqlAq8a9CnNfFXH/xHTbbB2Q=; b=bVkP4KoqcgGn+pcHg/caCbSQCn2thYQRkjWmVQAQoDcw2+IHXjbawmYtBYyNkJZbnQlueS 966CoSIKUw8kKEsf++HpAkf2dboSId0rTvO5Xf+tzfP9wRr92+F37GfirRunPyM2eRuAxg NNZ1zNQuLOnuX6p+a1RrTRxESx8WRXs= X-MC-Unique: 8V-4GagnOCi9xDi7gw8v0g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/36] virCgroupGetPercpuStats: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:21 +0100 Message-Id: <1769ab3fc55822bad306d1a21c69c8a41035c208.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.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: 1639052430631100003 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa --- src/util/vircgroup.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 51da6e6a2f..bf8db47ad4 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -2347,7 +2347,6 @@ virCgroupGetPercpuStats(virCgroup *group, unsigned int ncpus, virBitmap *guestvcpus) { - int ret =3D -1; size_t i; int need_cpus, total_cpus; char *pos; @@ -2356,7 +2355,7 @@ virCgroupGetPercpuStats(virCgroup *group, virTypedParameterPtr ent; int param_idx; unsigned long long cpu_time; - virBitmap *cpumap =3D NULL; + g_autoptr(virBitmap) cpumap =3D NULL; /* return the number of supported params */ if (nparams =3D=3D 0 && ncpus !=3D 0) { @@ -2373,21 +2372,19 @@ virCgroupGetPercpuStats(virCgroup *group, total_cpus =3D virBitmapSize(cpumap); /* return total number of cpus */ - if (ncpus =3D=3D 0) { - ret =3D total_cpus; - goto cleanup; - } + if (ncpus =3D=3D 0) + return total_cpus; if (start_cpu >=3D total_cpus) { virReportError(VIR_ERR_INVALID_ARG, _("start_cpu %d larger than maximum of %d"), start_cpu, total_cpus - 1); - goto cleanup; + return -1; } /* we get percpu cputime accounting info. */ if (virCgroupGetCpuacctPercpuUsage(group, &buf)) - goto cleanup; + return -1; pos =3D buf; /* return percpu cputime in index 0 */ @@ -2402,14 +2399,14 @@ virCgroupGetPercpuStats(virCgroup *group, } else if (virStrToLong_ull(pos, &pos, 10, &cpu_time) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cpuacct parse error")); - goto cleanup; + return -1; } if (i < start_cpu) continue; ent =3D ¶ms[(i - start_cpu) * nparams + param_idx]; if (virTypedParameterAssign(ent, VIR_DOMAIN_CPU_STATS_CPUTIME, VIR_TYPED_PARAM_ULLONG, cpu_time) < 0) - goto cleanup; + return -1; } /* return percpu vcputime in index 1 */ @@ -2419,7 +2416,7 @@ virCgroupGetPercpuStats(virCgroup *group, sum_cpu_time =3D g_new0(unsigned long long, need_cpus); if (virCgroupGetPercpuVcpuSum(group, guestvcpus, sum_cpu_time, need_cpus, cpumap) < 0) - goto cleanup; + return -1; for (i =3D start_cpu; i < need_cpus; i++) { int idx =3D (i - start_cpu) * nparams + param_idx; @@ -2427,17 +2424,13 @@ virCgroupGetPercpuStats(virCgroup *group, VIR_DOMAIN_CPU_STATS_VCPUTIME, VIR_TYPED_PARAM_ULLONG, sum_cpu_time[i]) < 0) - goto cleanup; + return -1; } param_idx++; } - ret =3D param_idx; - - cleanup: - virBitmapFree(cpumap); - return ret; + return param_idx; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052429; cv=none; d=zohomail.com; s=zohoarc; b=hpKMZJx9TtwM9RmCj1jmhRSmTH3ngQaNHfz7HlPlW+pZsgZGFEsBjJqBK4hvosJmLmZ358jCqNHKcKAh9eACCiXttQ00frsfCyLWM0IVwPaxJiQQiBo0N+z+nAEgxaCr23D/nG8zPuTqGAlmgLrHhGGSTlTWDUzjArZxC0FKuAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052429; 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=9t+KNI4Ucm77oSkIFVVmvxXtxubLbnCMybkaoKLteIU=; b=Xk0m6ZW6kUuQT9lw20TEc4LzmI0DwOvFBly56b5zaPuEJ6p7/d0IFhxrUt/YH2gYtMa+EKW+7mUjtIJ7hN4WI8wrvHraVEBcdX1igOQm7dEkKfeo1As3FifSfhSM/MYvAkT7+maLT5wSnKlK60eIhRuFQ4R4T3cnirqM85ksK5w= 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 1639052429256953.6261895777469; Thu, 9 Dec 2021 04:20:29 -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-406-MFw8VOMRO5unCFWFqqoioA-1; Thu, 09 Dec 2021 07:20:25 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68EC38015CD; Thu, 9 Dec 2021 12:20:20 +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 452045BE05; Thu, 9 Dec 2021 12:20:20 +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 165AF4A708; Thu, 9 Dec 2021 12:20:20 +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 1B9CKIme014542 for ; Thu, 9 Dec 2021 07:20:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id A319717DBA; Thu, 9 Dec 2021 12:20:18 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9B765ED38 for ; Thu, 9 Dec 2021 12:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052428; 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=9t+KNI4Ucm77oSkIFVVmvxXtxubLbnCMybkaoKLteIU=; b=JdOBjg5hiiWvwpsgBNaQIY1sJnk/2tr3jWyJeXg8So31KwH9m8fnmzE6k/96Jt4Rp1Dz4X ckZAPvG6rjQSmAP9HlSnmwUkixmskhzid4nVs6LH/q+r+yP9lwl2lAb08WCK2Q2totjxHy NWhpG8xTOqrZ3c0E+CG8jJ+rSQGiRco= X-MC-Unique: MFw8VOMRO5unCFWFqqoioA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/36] virshParseCPUList: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:22 +0100 Message-Id: <148f577e26fec9b1805492b7deca4381de133ce4.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.15 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: 1639052430427100001 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 8379f9f135..2338d6522a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6983,7 +6983,7 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen, const char *cpulist, int maxcpu) { unsigned char *cpumap =3D NULL; - virBitmap *map =3D NULL; + g_autoptr(virBitmap) map =3D NULL; if (cpulist[0] =3D=3D 'r') { map =3D virBitmapNew(maxcpu); @@ -6994,21 +6994,19 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen, if (virBitmapParse(cpulist, &map, 1024) < 0 || virBitmapIsAllClear(map)) { vshError(ctl, _("Invalid cpulist '%s'"), cpulist); - goto cleanup; + return NULL; } lastcpu =3D virBitmapLastSetBit(map); if (lastcpu >=3D maxcpu) { vshError(ctl, _("CPU %d in cpulist '%s' exceed the maxcpu %d"), lastcpu, cpulist, maxcpu); - goto cleanup; + return NULL; } } if (virBitmapToData(map, &cpumap, cpumaplen) < 0) - goto cleanup; + return NULL; - cleanup: - virBitmapFree(map); return cpumap; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052436; cv=none; d=zohomail.com; s=zohoarc; b=OeH673bIL/PjWJHAGmaHvtUUZAAL5EB5wEm/x8qXWGbS5f2czA0Qi5a/diycvqEzVtH7UadezOi14QsRVu1fXXk2ElYcC5gcixGGOdMmWIvnqpCzvjdCwmo9sJgWcM4fmgSVrgluuPuM80pjkPirqiPaDsGnxpmYZ8VdcDweil8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052436; 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=xq0GMMNecx2qtFhINPSiOs+yPGqnXaZbwTZdKAIt7uk=; b=gbjLwc1YrNoiRDfBcScIz5N2yCSkX0VxfhZy0Gso++Ya26DlN88dO+/pAQeJr8iGxJYT96owEMKDsePhUpZeZIzkr2C206s21pU7m7CUzr4dKtoYjrUrP6734A7sbgA+suBpKBjHNXCcEN9oGuA+cwgSY51WfNtY7mQI1C0mfAk= 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 1639052436239270.9166062741449; Thu, 9 Dec 2021 04:20:36 -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-397-WPs_6lGbMOKzcmwVS8zGaw-1; Thu, 09 Dec 2021 07:20:31 -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 DC37D100E325; Thu, 9 Dec 2021 12:20:24 +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 BE2146B8EE; Thu, 9 Dec 2021 12:20:24 +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 93AB74A70A; Thu, 9 Dec 2021 12:20:24 +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 1B9CKJcT014548 for ; Thu, 9 Dec 2021 07:20:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id C6E7B17DBA; Thu, 9 Dec 2021 12:20:19 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D26A5ED38 for ; Thu, 9 Dec 2021 12:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052435; 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=xq0GMMNecx2qtFhINPSiOs+yPGqnXaZbwTZdKAIt7uk=; b=LXeNCIG+t8AyN2snteWJlPop6UO8j8cb9CgJ+kzvqgcR95fNsLOM9Bt/YPgMXLuxcbN3rt Y3Ekjdz9mZ0Mf5OOdFi9/xahd7mREEl3ohJ/rp4/PqVmsxWMJt1iGTWy3mcXUv+Gud5O1Y WPj0hGdqBTbKJYBlnlPRZny5vT15iVo= X-MC-Unique: WPs_6lGbMOKzcmwVS8zGaw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/36] virnumamock: Use automatic memory freeing for virBitmap Date: Thu, 9 Dec 2021 13:18:23 +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.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: 1639052438307100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virnumamock.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/virnumamock.c b/tests/virnumamock.c index 19c26d1e37..7f2653cb53 100644 --- a/tests/virnumamock.c +++ b/tests/virnumamock.c @@ -63,29 +63,23 @@ virNumaIsAvailable(void) int virNumaGetMaxNode(void) { - int ret =3D -1; - virBitmap *map =3D NULL; + g_autoptr(virBitmap) map =3D NULL; if (virFileReadValueBitmap(&map, "%s/node/online", SYSFS_SYSTEM_PATH) = < 0) return -1; - ret =3D virBitmapLastSetBit(map); - virBitmapFree(map); - return ret; + return virBitmapLastSetBit(map); } bool virNumaNodeIsAvailable(int node) { - bool ret =3D false; - virBitmap *map =3D NULL; + g_autoptr(virBitmap) map =3D NULL; if (virFileReadValueBitmap(&map, "%s/node/online", SYSFS_SYSTEM_PATH) = < 0) return false; - ret =3D virBitmapIsBitSet(map, node); - virBitmapFree(map); - return ret; + return virBitmapIsBitSet(map, node); } int --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052436; cv=none; d=zohomail.com; s=zohoarc; b=gabG+PX47zgXeqsZY+p9Imz0LWsjC0KYZVfRU3Vto055vUFmxWo0pb1Ku9kGBYJckjbdyoYinz/9gha0nIIPQxZqSea8gTsQyzZ5MA/ZQCEeh7e+pCKqzYMr1rCtyUSCnIAr/T7/k8aZS+qOWTyrAXxjn2pX6Jc2geA0j8IKuyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052436; 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=JufFG6DRwkLl2dG3iBxyQrzK7NsOf2V5eYrQ+kRvMXM=; b=M8YZ3YjYdJwMQQNeD9qCEX/KE2yUMY+Yf8zl4Wx2Qwn7+8CoQa4sGditzLHc/GssjRn4C9B8DGzW4C/hDyM8U6DJYIeku0s39ZEznfWWphz5g0dOG+2A7cxMK9w3jdn+Fr7jN/nCKq/8wVgy4ivyCRC8hkFOiMa5o0jczVx6HoQ= 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 1639052436715661.3955722089755; Thu, 9 Dec 2021 04:20:36 -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-532-zsgAtcAcOsKibcFIexNyNQ-1; Thu, 09 Dec 2021 07:20:32 -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 AF1385F9CA; Thu, 9 Dec 2021 12:20:27 +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 4C2E245D79; Thu, 9 Dec 2021 12:20:27 +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 12B5B1802FE9; Thu, 9 Dec 2021 12:20:27 +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 1B9CKKpc014561 for ; Thu, 9 Dec 2021 07:20:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id E16F317DBA; Thu, 9 Dec 2021 12:20:20 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E1665ED38 for ; Thu, 9 Dec 2021 12:20:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052435; 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=JufFG6DRwkLl2dG3iBxyQrzK7NsOf2V5eYrQ+kRvMXM=; b=GpC6+r5PW6LMNdi0OBcphmvntIRLwTjJImGzYCy/rMT1vg4cTaEZsJmZQUghidp7AqpmSD XG23VMiJ0ttQDJD0cZJRzWJJ5+/H8cqG0H2DcMLGC5IdIXmTeqz7M7yZoLwNodipQKL7vi Iv0IEZG8itcCJSJA9LCrHVB2oODOnlc= X-MC-Unique: zsgAtcAcOsKibcFIexNyNQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/36] test_virCapabilitiesGetCpusForNodemask: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:24 +0100 Message-Id: <793d1a914dbb3b3dfca8701b2789148d84649ece.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.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: 1639052438433100002 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/vircapstest.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/vircapstest.c b/tests/vircapstest.c index d1b5033844..697803fdc9 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -33,28 +33,21 @@ static int test_virCapabilitiesGetCpusForNodemask(const void *data G_GNUC_UNUSED) { const char *nodestr =3D "3,4,5,6"; - virBitmap *nodemask =3D NULL; - virBitmap *cpumap =3D NULL; + g_autoptr(virBitmap) nodemask =3D NULL; + g_autoptr(virBitmap) cpumap =3D NULL; g_autoptr(virCapsHostNUMA) caps =3D NULL; int mask_size =3D 8; - int ret =3D -1; if (!(caps =3D virTestCapsBuildNUMATopology(3))) - goto error; + return -1; if (virBitmapParse(nodestr, &nodemask, mask_size) < 0) - goto error; + return -1; if (!(cpumap =3D virCapabilitiesHostNUMAGetCpus(caps, nodemask))) - goto error; - - ret =3D 0; - - error: - virBitmapFree(nodemask); - virBitmapFree(cpumap); - return ret; + return -1; + return 0; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052469; cv=none; d=zohomail.com; s=zohoarc; b=PcfoIugdVSMWSa+vqyBNchn31FBFd0AeoLA/xJRZveI+TISt6zX5KI5t2CIWD/fE0ELB6xltvHGdKnJSmVMHwvQgGPeH7Epuf1we8u/3ZGMBOsh7eHNAE0z0JEDs0vOgvFb46qyQ1DQuk2s1eewCH5IUkEjBjWr3fntdfGrXWeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052469; 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=K8IyrxslqrlWy3yo0OSTfHTNoQjNYdlMynmlqjiM4Q4=; b=HbN2vJLk8mIiwy59okSKi3asxFh33XuGTcn+nl8VZTKpAgKla0BHRcqvDNO1EQYBOdkclc8bzGCx6Yoiw5rTZL0rhN6S+gpR5r6/0ybliXl0GABgpZVuk1+6FsCf+Xjo9z7wFoFoooEQZIokS9gYzVjsP2oZI1FZJfKtNIFmYVk= 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 163905246918361.34835130375086; Thu, 9 Dec 2021 04:21:09 -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-587-DGp9Spu8OcKA9wXZ4Gtxhg-1; Thu, 09 Dec 2021 07:20:37 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 15F381006ADC; Thu, 9 Dec 2021 12:20:28 +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 D13018462D; Thu, 9 Dec 2021 12:20:27 +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 983714A70A; Thu, 9 Dec 2021 12:20:27 +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 1B9CKM5N014570 for ; Thu, 9 Dec 2021 07:20:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id EF8F017DBA; Thu, 9 Dec 2021 12:20:21 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 598FA5ED38 for ; Thu, 9 Dec 2021 12:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052468; 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=K8IyrxslqrlWy3yo0OSTfHTNoQjNYdlMynmlqjiM4Q4=; b=R35iC6pEIqWyPxk56FfhEqTUnECX6AE9C3DdKyc9W4/jiohJgNl69FkPhhhLnEIFDczR20 DBMCLmMmcb6jBGI7REgkQSGTLv5tfaDAKFhtyRyKS/vEL5/3ITQH2b6Q94re0S0nwdaL6p tN3vb4XPPN98ipoa94zh8wt2pae3Jz4= X-MC-Unique: DGp9Spu8OcKA9wXZ4Gtxhg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/36] util: bitmap: Unexport 'virBitmapParseSeparator' Date: Thu, 9 Dec 2021 13:18:25 +0100 Message-Id: <603e1f120c9c056721cb235b80b2a05b0a61f29f.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.13 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: 1639052470418100003 Content-Type: text/plain; charset="utf-8" The function isn't used besides tests. Since the separator parsing capability is trivial we can keep it in place and just unexport it for now. Signed-off-by: Peter Krempa --- src/libvirt_private.syms | 1 - src/util/virbitmap.c | 2 +- src/util/virbitmap.h | 5 ----- tests/virbitmaptest.c | 2 +- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7be5b51100..ac0a704750 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1851,7 +1851,6 @@ virBitmapNextClearBit; virBitmapNextSetBit; virBitmapOverlaps; virBitmapParse; -virBitmapParseSeparator; virBitmapParseUnlimited; virBitmapSetAll; virBitmapSetBit; diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index ee76fec8cd..5f14f1e5e0 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -397,7 +397,7 @@ virBitmapFormat(virBitmap *bitmap) * * Returns 0 on success, or -1 in case of error. */ -int +static int virBitmapParseSeparator(const char *str, char terminator, virBitmap **bitmap, diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 026659544e..48074d1ae6 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -81,11 +81,6 @@ int virBitmapParse(const char *str, virBitmap **bitmap, size_t bitmapSize) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -int -virBitmapParseSeparator(const char *str, - char terminator, - virBitmap **bitmap, - size_t bitmapSize); virBitmap * virBitmapParseUnlimited(const char *str); diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 02241c4c20..1794f73f34 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -497,7 +497,7 @@ test10(const void *opaque G_GNUC_UNUSED) g_autoptr(virBitmap) b3 =3D NULL; g_autoptr(virBitmap) b4 =3D NULL; - if (virBitmapParseSeparator("0-3,5-8,11-15f16", 'f', &b1, 20) < 0 || + if (virBitmapParse("0-3,5-8,11-15", &b1, 20) < 0 || virBitmapParse("4,9,10,16-19", &b2, 20) < 0 || virBitmapParse("15", &b3, 20) < 0 || virBitmapParse("0,^0", &b4, 20) < 0) --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052441; cv=none; d=zohomail.com; s=zohoarc; b=QcweeZ1sdi4EBGps8UIP5Ie0Eqz1atKoVBupho9+MqmwRcwuM1/cAtnXEYcu5xmqlZOXVNSRFk0+ZAWmRZ+RYLoVaMpc3UNFnzeKyA3v3boENXvqq/356dIhOwTykw7RIfrDw7Iiv9ilcV9PxpMsoZAb5feQONPYwHyG53DBydI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052441; 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=4pEXcp9i7xzUy+YOqQeOrzB74rUdt7AKjeuZbSqcNyI=; b=JmZss0hDidrFQ0DoD3TCacwnOOiv0TV5r544SaX9G81TwtnJ618D5+bfNKe21ngOJcQeCQt4sCtiXyxdqv5K79MAY21MLmqpCRzpxjDlXcq804vy6ULVvZx7lqG7p/mNQDseILRDINiZvNE2xbIt4l09rtNTvaqFajz1RK7P4+o= 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 1639052441132356.0678895696534; Thu, 9 Dec 2021 04:20:41 -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-301-NF6_cOF3OcSYDONm8q4_TQ-1; Thu, 09 Dec 2021 07:20:36 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D987E802CBE; Thu, 9 Dec 2021 12:20:30 +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 880A5103BAAF; Thu, 9 Dec 2021 12:20:30 +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 54E494A70A; Thu, 9 Dec 2021 12:20:30 +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 1B9CKNC1014590 for ; Thu, 9 Dec 2021 07:20:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0981B5ED2A; Thu, 9 Dec 2021 12:20:23 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60E705E26C for ; Thu, 9 Dec 2021 12:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052440; 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=4pEXcp9i7xzUy+YOqQeOrzB74rUdt7AKjeuZbSqcNyI=; b=RMHEzL+GJMZ2tX+limnyW59RH8sbJU9lXSFgpQc98VI3Oeo6xcxMxEwiAe4aQBKm+zaW+3 XJbMIAF/6pwHjbl0VJE5nIdRYIi0WcpVfmCKRJksrWNkWU0OT7u6heyC0YqY6pu70eI64Q st99HObGnzIlZA/Mgg7F/kzR5u/7VV8= X-MC-Unique: NF6_cOF3OcSYDONm8q4_TQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/36] virBitmapExpand: Remove return value Date: Thu, 9 Dec 2021 13:18:26 +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.84 on 10.5.11.22 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: 1639052441957100001 Content-Type: text/plain; charset="utf-8" There's nothing that can fail in the function. Remove the return value and adjust callers. Signed-off-by: Peter Krempa --- src/util/virbitmap.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 5f14f1e5e0..2b885803fd 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -128,10 +128,8 @@ virBitmapSetBit(virBitmap *bitmap, * * Resizes the bitmap so that bit @b will fit into it. This shall be calle= d only * if @b would not fit into the map. - * - * Returns 0 on success, -1 on error. */ -static int +static void virBitmapExpand(virBitmap *map, size_t b) { @@ -145,8 +143,6 @@ virBitmapExpand(virBitmap *map, map->nbits =3D b + 1; map->map_len =3D new_len; - - return 0; } @@ -164,8 +160,8 @@ int virBitmapSetBitExpand(virBitmap *bitmap, size_t b) { - if (bitmap->nbits <=3D b && virBitmapExpand(bitmap, b) < 0) - return -1; + if (bitmap->nbits <=3D b) + virBitmapExpand(bitmap, b); bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] |=3D VIR_BITMAP_BIT(b); return 0; @@ -208,8 +204,7 @@ virBitmapClearBitExpand(virBitmap *bitmap, size_t b) { if (bitmap->nbits <=3D b) { - if (virBitmapExpand(bitmap, b) < 0) - return -1; + virBitmapExpand(bitmap, b); } else { bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] &=3D ~VIR_BITMAP_BIT(b); } @@ -1178,10 +1173,8 @@ virBitmapUnion(virBitmap *a, { size_t i; - if (a->nbits < b->nbits && - virBitmapExpand(a, b->nbits - 1) < 0) { - return -1; - } + if (a->nbits < b->nbits) + virBitmapExpand(a, b->nbits - 1); for (i =3D 0; i < b->map_len; i++) a->map[i] |=3D b->map[i]; --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052525; cv=none; d=zohomail.com; s=zohoarc; b=IrHL6IuJkZUBW5Cxqkq2BumR8izMKjKafusaIn5GILgDIo0MDCdi7Fd80BunAKumdXk6XI0K9p4uil+qN2d7mkuHJy0cKpORCWGEahh2et+R14Rp6R7vAHH9/K+x4Jl7WnCsXTa1piFtB692eUPppG7csvn1W/hStnrOTLP4Bw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052525; 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=SW7V+SZWHJFp3SN+nE9bwIuDGCJCWSVHz9D9RWMh6aM=; b=lUnXP3JdVoPRvM/TQ7onmquz0gL9xuBM3hJ5QK4Q6iz+CFl6fU4om4XmMMTR6h5VXxbpaKPb/AJ45WQnrxPu34nmC1xBSO38/FRjKfLLBFVoWMkw9/uMoABBzQvj61q6PkE49nv+bxs1DqFVFEy4c/heSuoi/PcHWsycGNDpOhc= 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) 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 1639052525682699.9858271730268; Thu, 9 Dec 2021 04:22:05 -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-539-brzxTNfPP76K07h-Ebci5w-1; Thu, 09 Dec 2021 07:20:35 -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 022ED802CBA; Thu, 9 Dec 2021 12:20:30 +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 D278A45D74; Thu, 9 Dec 2021 12:20:29 +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 9F2751802E2C; Thu, 9 Dec 2021 12:20:29 +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 1B9CKOpF014601 for ; Thu, 9 Dec 2021 07:20:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 23B1C5E26C; Thu, 9 Dec 2021 12:20:24 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8222F5ED39 for ; Thu, 9 Dec 2021 12:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052524; 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=SW7V+SZWHJFp3SN+nE9bwIuDGCJCWSVHz9D9RWMh6aM=; b=SIpDfyraMUxXE1Ct9+kpGetRiTwMMlHkrSRz5b5k56cr8YrfVDnoUVpJPGR+Hd93GUHhcN +MI0rZscZSPrJcGcYWDBZIGZOh2TFZ99ygIxhxdOmdNySWR63lByQUbOWZrfUoV7/9I3iq V7yf77e2yw5+LRxIiPhOs/q3AAI4u6U= X-MC-Unique: brzxTNfPP76K07h-Ebci5w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/36] virBitmapUnion: Remove return value Date: Thu, 9 Dec 2021 13:18:27 +0100 Message-Id: <9132682fae8f4038b5e660fdbf2cab095bbac2f8.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.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: 1639052527754100003 Content-Type: text/plain; charset="utf-8" The function can't fail at this point. Remove the return value. Signed-off-by: Peter Krempa --- src/util/virbitmap.c | 6 +----- src/util/virbitmap.h | 4 ++-- src/util/virnuma.c | 3 +-- tests/virbitmaptest.c | 3 +-- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 2b885803fd..c067b1f738 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -1164,10 +1164,8 @@ virBitmapIntersect(virBitmap *a, * @b: other bitmap * * Performs union of two bitmaps: a =3D union(a, b) - * - * Returns 0 on success, <0 on failure. */ -int +void virBitmapUnion(virBitmap *a, const virBitmap *b) { @@ -1178,8 +1176,6 @@ virBitmapUnion(virBitmap *a, for (i =3D 0; i < b->map_len; i++) a->map[i] |=3D b->map[i]; - - return 0; } diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 48074d1ae6..23242b44ff 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -133,8 +133,8 @@ bool virBitmapOverlaps(virBitmap *b1, void virBitmapIntersect(virBitmap *a, virBitmap *b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -int virBitmapUnion(virBitmap *a, - const virBitmap *b) +void virBitmapUnion(virBitmap *a, + const virBitmap *b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); void virBitmapSubtract(virBitmap *a, virBitmap *b) diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 31f65d8902..7c892d6267 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -333,8 +333,7 @@ virNumaNodesetToCPUset(virBitmap *nodeset, return -1; } - if (virBitmapUnion(allNodesCPUs, nodeCPUs) < 0) - return -1; + virBitmapUnion(allNodesCPUs, nodeCPUs); } *cpuset =3D g_steal_pointer(&allNodesCPUs); diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 1794f73f34..4c525679f6 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -665,8 +665,7 @@ test15(const void *opaque) return -1; } - if (virBitmapUnion(amap, bmap) < 0) - return -1; + virBitmapUnion(amap, bmap); if (!virBitmapEqual(amap, resmap)) { fprintf(stderr, --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052473; cv=none; d=zohomail.com; s=zohoarc; b=P+y0CC548b+Dg0THIRLkWwqQW7atXBtxFqvJ9fbRhBLHPec1HiZ/Ln5vG6OCrNv4dHeqJ8dIm2PRMjWdS17hqZwpemEf77NK5XqEta9JpF74UzOOz1UfQ9z+eBz/fesQeAcbTNBy4uOnxlnGJFhXf3HfF6p5kl4ecL1RrFkLvYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052473; 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=yRlkUo/rP2wF3xs9X/dCBpBtuTYwo/aje2X19NkeV00=; b=EKg2M3dbSBhmBHhtRnu3NqMLbdLe5yFltBDVXvn+Fy1kcApcLpghOJApfMkPHDyC5t9jRTBkIwiVQAA1C/dmg/HXyZRCmn5W8TIVde7D6SFCT2YO4U9jvs8cgvhHkuU1U4hCi7TLjlrHfm6WP6v56fIfti93ce+nUkCDj4FdI8w= 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 1639052473611471.7965995378818; Thu, 9 Dec 2021 04:21:13 -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-433-ckuL8W-SMVe0ZWGGueVu4w-1; Thu, 09 Dec 2021 07:21:09 -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 1A178801AC5; Thu, 9 Dec 2021 12:21:04 +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 9101B1ABE5; Thu, 9 Dec 2021 12:21:03 +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 633124A706; Thu, 9 Dec 2021 12:21:03 +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 1B9CL1St014975 for ; Thu, 9 Dec 2021 07:21:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id D78635ED37; Thu, 9 Dec 2021 12:21:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D0915E26C for ; Thu, 9 Dec 2021 12:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052472; 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=yRlkUo/rP2wF3xs9X/dCBpBtuTYwo/aje2X19NkeV00=; b=EqLppLwViQtMSAtTip3EfSF+cjs2ZQFR+GPC7v3mVHxpCdNklOxxqmpqxqfaK5rVeh2lYL TEsHE7TGA3OxBfem62Gn22ENUOPkSIfzjsyZS9LOMG3XF4PrrlIYwPzJyREo6DA49uQEUm P9FqqUGi1+YQZJqaTZuuwogaiqiFjyc= X-MC-Unique: ckuL8W-SMVe0ZWGGueVu4w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 23/36] virBitmapClearBitExpand: Remove return value Date: Thu, 9 Dec 2021 13:18:28 +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.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: 1639052475589100001 Content-Type: text/plain; charset="utf-8" The function can't fail at this point. Remove the return value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virbitmap.c | 9 ++------- src/util/virbitmap.h | 4 ++-- tests/virbitmaptest.c | 3 +-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index c067b1f738..ecc4b96a57 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -196,10 +196,8 @@ virBitmapClearBit(virBitmap *bitmap, * * Clear bit position @b in @bitmap. Expands the bitmap as necessary so th= at * @b is included in the map. - * - * Returns 0 on if bit is successfully cleared, -1 on error. */ -int +void virBitmapClearBitExpand(virBitmap *bitmap, size_t b) { @@ -208,8 +206,6 @@ virBitmapClearBitExpand(virBitmap *bitmap, } else { bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] &=3D ~VIR_BITMAP_BIT(b); } - - return 0; } @@ -573,8 +569,7 @@ virBitmapParseUnlimited(const char *str) if (*cur =3D=3D ',' || *cur =3D=3D 0) { if (neg) { - if (virBitmapClearBitExpand(bitmap, start) < 0) - goto error; + virBitmapClearBitExpand(bitmap, start); } else { if (virBitmapSetBitExpand(bitmap, start) < 0) goto error; diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 23242b44ff..08ada97aa1 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -54,8 +54,8 @@ int virBitmapSetBitExpand(virBitmap *bitmap, size_t b) int virBitmapClearBit(virBitmap *bitmap, size_t b) ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; -int virBitmapClearBitExpand(virBitmap *bitmap, size_t b) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; +void virBitmapClearBitExpand(virBitmap *bitmap, size_t b) + ATTRIBUTE_NONNULL(1); /* * Get bit @b in @bitmap. Returns false if b is out of range. diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 4c525679f6..f16df4d2b2 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -564,8 +564,7 @@ test12a(const void *opaque G_GNUC_UNUSED) if (checkBitmap(map, "128", 129) < 0) return -1; - if (virBitmapClearBitExpand(map, 150) < 0) - return -1; + virBitmapClearBitExpand(map, 150); if (checkBitmap(map, "128", 151) < 0) return -1; --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052508; cv=none; d=zohomail.com; s=zohoarc; b=XCwEFuRMQ+H2eaO8VUIuLjpGc717O0XsmdK8rwPiO6BCyEPlOygomJrDTd89qK1lXhgDdYsBPuSf4GN5yk91BZsHPpquGKdIOBuExY4uhb19BZJ9IF32EUM3UgnBVNvyv/snbI4NAFsGVSOVvAtY88YJhmChxR4diOxS66EKeQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052508; 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=EL7BKs/QTjRG7qx4ne9ol5ANtmdSAIP7LMIO0C3+Cr4=; b=igBGuAaZLwPAvzzxdI/6+mJCbbsVtEBUymuT+cl+iHq2FPKQLATbRiseE6J6d6T4QouHQRfrOJC1hjT6NT+tsAzqGjyjSpG0gjyccU13Jf6HuYVp0V+svZmi6oshxQaSzbLdwlvqxjTbx9K/0GXIEmLX1xmM7ZKRZT+p+0kH6xo= 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 1639052508224400.0658614536121; Thu, 9 Dec 2021 04:21: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-495-25a-jKVsNcej-E8k7n9zYg-1; Thu, 09 Dec 2021 07:21:45 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E6BDE8710F1; Thu, 9 Dec 2021 12:21: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 CA87410023AE; Thu, 9 Dec 2021 12:21: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 9C5D14A705; Thu, 9 Dec 2021 12:21: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 1B9CLcgk015365 for ; Thu, 9 Dec 2021 07:21:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id CF7F95ED31; Thu, 9 Dec 2021 12:21:38 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 356F55ED2F for ; Thu, 9 Dec 2021 12:21:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052507; 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=EL7BKs/QTjRG7qx4ne9ol5ANtmdSAIP7LMIO0C3+Cr4=; b=EDMWchaaNGsCJWT/MT55sL6qvDLjs3asydK1VfOzy5dH8D/p9hbm+6i/H6Rc3uGYx+rUgN 5BilBQlpgemOoQGwovHl2lO0hmJmIidZU4Nnn2shkfix1LQQIemewkKB2d/ByvlMDe+P49 fbQlZLPZ2H9+9mBATvgdH1OeGpRWPso= X-MC-Unique: 25a-jKVsNcej-E8k7n9zYg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 24/36] virBitmapSetBitExpand: Remove return value Date: Thu, 9 Dec 2021 13:18:29 +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.84 on 10.5.11.22 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: 1639052509856100001 Content-Type: text/plain; charset="utf-8" The function can't fail at this point. Remove the return value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/numa_conf.c | 3 +-- src/network/bridge_driver.c | 3 +-- src/util/virbitmap.c | 14 ++++---------- src/util/virbitmap.h | 4 ++-- src/util/virhostcpu.c | 6 ++---- src/util/virqemu.c | 3 +-- src/util/virtpm.c | 3 +-- tests/testutils.c | 2 +- tests/virbitmaptest.c | 7 +++---- 9 files changed, 16 insertions(+), 29 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 3bc1f63a5d..32821bf6a3 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -1149,8 +1149,7 @@ virDomainNumaDefValidate(const virDomainNuma *def) return -1; } - if (virBitmapSetBitExpand(levelsSeen, cache->level)) - return -1; + virBitmapSetBitExpand(levelsSeen, cache->level); } } diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 7e5fab630b..40dccf2c15 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4966,8 +4966,7 @@ networkNextClassID(virNetworkObj *obj) if ((ret =3D virBitmapNextClearBit(classIdMap, -1)) < 0) ret =3D virBitmapSize(classIdMap); - if (virBitmapSetBitExpand(classIdMap, ret) < 0) - return -1; + virBitmapSetBitExpand(classIdMap, ret); return ret; } diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index ecc4b96a57..a3f674eb19 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -153,10 +153,8 @@ virBitmapExpand(virBitmap *map, * * Set bit position @b in @bitmap. Expands the bitmap as necessary so that= @b is * included in the map. - * - * Returns 0 on if bit is successfully set, -1 on error. */ -int +void virBitmapSetBitExpand(virBitmap *bitmap, size_t b) { @@ -164,7 +162,6 @@ virBitmapSetBitExpand(virBitmap *bitmap, virBitmapExpand(bitmap, b); bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] |=3D VIR_BITMAP_BIT(b); - return 0; } @@ -571,8 +568,7 @@ virBitmapParseUnlimited(const char *str) if (neg) { virBitmapClearBitExpand(bitmap, start); } else { - if (virBitmapSetBitExpand(bitmap, start) < 0) - goto error; + virBitmapSetBitExpand(bitmap, start); } } else if (*cur =3D=3D '-') { if (neg) @@ -588,10 +584,8 @@ virBitmapParseUnlimited(const char *str) cur =3D tmp; - for (i =3D start; i <=3D last; i++) { - if (virBitmapSetBitExpand(bitmap, i) < 0) - goto error; - } + for (i =3D start; i <=3D last; i++) + virBitmapSetBitExpand(bitmap, i); virSkipSpaces(&cur); } diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 08ada97aa1..e2314904b0 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -44,8 +44,8 @@ void virBitmapFree(virBitmap *bitmap); int virBitmapSetBit(virBitmap *bitmap, size_t b) ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; -int virBitmapSetBitExpand(virBitmap *bitmap, size_t b) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; +void virBitmapSetBitExpand(virBitmap *bitmap, size_t b) + ATTRIBUTE_NONNULL(1); /* diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 1920184f61..83e3a5d0f1 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -336,8 +336,7 @@ virHostCPUParseNode(const char *node, if (virHostCPUGetSocket(cpu, &sock) < 0) goto cleanup; - if (virBitmapSetBitExpand(sockets_map, sock) < 0) - goto cleanup; + virBitmapSetBitExpand(sockets_map, sock); if (sock > sock_max) sock_max =3D sock; @@ -396,8 +395,7 @@ virHostCPUParseNode(const char *node, goto cleanup; } - if (virBitmapSetBitExpand(cores_maps[sock], core) < 0) - goto cleanup; + virBitmapSetBitExpand(cores_maps[sock], core); if (!(siblings =3D virHostCPUCountThreadSiblings(cpu))) goto cleanup; diff --git a/src/util/virqemu.c b/src/util/virqemu.c index aef6006dd7..8ff61b22b0 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -70,8 +70,7 @@ virQEMUBuildCommandLineJSONArrayBitmap(const char *key, if (virJSONValueGetNumberUlong(member, &value) < 0) return -1; - if (virBitmapSetBitExpand(bitmap, value) < 0) - return -1; + virBitmapSetBitExpand(bitmap, value); } while ((pos =3D virBitmapNextSetBit(bitmap, pos)) > -1) { diff --git a/src/util/virtpm.c b/src/util/virtpm.c index 63579b8e69..cf4c7c458f 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -251,8 +251,7 @@ virTPMExecGetCaps(virCommand *cmd, if (typ < 0) continue; - if (virBitmapSetBitExpand(bitmap, typ) < 0) - return bitmap; + virBitmapSetBitExpand(bitmap, typ); } return bitmap; diff --git a/tests/testutils.c b/tests/testutils.c index e460c9ecc5..65f02e0231 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -173,7 +173,7 @@ virTestRun(const char *title, } if (ret !=3D 0 && ret !=3D EXIT_AM_SKIP) - ignore_value(virBitmapSetBitExpand(failedTests, testCounter)); + virBitmapSetBitExpand(failedTests, testCounter); g_unsetenv("VIR_TEST_MOCK_TESTNAME"); return ret; diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index f16df4d2b2..89dc702da2 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -558,8 +558,7 @@ test12a(const void *opaque G_GNUC_UNUSED) if (checkBitmap(map, "", 0) < 0) return -1; - if (virBitmapSetBitExpand(map, 128) < 0) - return -1; + virBitmapSetBitExpand(map, 128); if (checkBitmap(map, "128", 129) < 0) return -1; @@ -692,8 +691,8 @@ test16(const void *opaque G_GNUC_UNUSED) return -1; } - ignore_value(virBitmapSetBitExpand(map, 2)); - ignore_value(virBitmapSetBitExpand(map, 11)); + virBitmapSetBitExpand(map, 2); + virBitmapSetBitExpand(map, 11); if (!(res_set =3D virBitmapToString(map)) || STRNEQ_NULLABLE(res_set, "804")) { --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052533; cv=none; d=zohomail.com; s=zohoarc; b=eFXfLkKXCkDw64hGaEZBlGjSqbt3jdly9JKK9qonlgugwwD35+ZJ9gl+Q9Lul9KyVtBWK3fP8KFfnuojMA/z115LpZQu7GIalk68aFItyh3MYgKXfE/FxKvXNiLNbKCtMJuylkCDHvMJ1tXSs8B5jP8IpSaQc4JXjOhVDUzqL7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052533; 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=2H5+5PQOqGl2rH1SU/SfmbnBytPKzKQE3CGyoYIB/Ls=; b=oGBvHtdFakQpcB5IUMPcFoXdIlQzwGbEeFGc/xrY4a6lFtF9Yc3NxxnspcfrSh8YQFCxkILGRLiuQ0jFkizF7ZUZYTW/Iq+WSXzOkah5H4Q8i/Msd0kwzWYY9ta9ME6/8SNudbkCw5VggTppMjtyr1buVxyw1UFW55QNUGIru+M= 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 1639052533640715.1154659566943; Thu, 9 Dec 2021 04:22:13 -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-25-9BJniLDHN3W__nH3nKEqGg-1; Thu, 09 Dec 2021 07:22:11 -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 C806018A0F26; Thu, 9 Dec 2021 12:22:05 +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 AF91860657; Thu, 9 Dec 2021 12:22:05 +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 7364C1802E2C; Thu, 9 Dec 2021 12:22:05 +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 1B9CM3hY015468 for ; Thu, 9 Dec 2021 07:22:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9DD415ED2B; Thu, 9 Dec 2021 12:22:03 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 042B75ED27 for ; Thu, 9 Dec 2021 12:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052532; 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=2H5+5PQOqGl2rH1SU/SfmbnBytPKzKQE3CGyoYIB/Ls=; b=aqbK20U7clfyor2wOJWeiPRRWOxNBY9vEwzNoV2LGKP0YNelCZYSHvW/cZQPNo7vbfqhIn Xv0ewtb/1DbbgMnIyxijqRljwFyXxxqvq3gPW1qozNPLyAyzGhEDjNg3emsnRL5tx4zWKO 1mn3GGagoZ320lJXFugL4i9u34ZN4jU= X-MC-Unique: 9BJniLDHN3W__nH3nKEqGg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 25/36] virBitmapParseSeparator: Remove separator parsing capability Date: Thu, 9 Dec 2021 13:18:30 +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: 1639052535613100001 Content-Type: text/plain; charset="utf-8" Since the feature is not needed remove it and remove the function to virBitmapParseInternal. Signed-off-by: Peter Krempa --- src/util/virbitmap.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index a3f674eb19..1aaefba133 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -364,9 +364,8 @@ virBitmapFormat(virBitmap *bitmap) /** - * virBitmapParseSeparator: + * virBitmapParseInternal: * @str: points to a string representing a human-readable bitmap - * @terminator: character separating the bitmap to parse * @bitmap: a bitmap created from @str * @bitmapSize: the upper limit of num of bits in created bitmap * @@ -377,19 +376,12 @@ virBitmapFormat(virBitmap *bitmap) * to set, and ^N, which means to unset the bit, and N-M for ranges of bits * to set. * - * To allow parsing of bitmaps within larger strings it is possible to set - * a termination character in the argument @terminator. When the character - * in @terminator is encountered in @str, the parsing of the bitmap stops. - * Pass 0 as @terminator if it is not needed. Whitespace characters may not - * be used as terminators. - * * Returns 0 on success, or -1 in case of error. */ static int -virBitmapParseSeparator(const char *str, - char terminator, - virBitmap **bitmap, - size_t bitmapSize) +virBitmapParseInternal(const char *str, + virBitmap **bitmap, + size_t bitmapSize) { bool neg =3D false; const char *cur =3D str; @@ -407,7 +399,7 @@ virBitmapParseSeparator(const char *str, if (*cur =3D=3D '\0') goto error; - while (*cur !=3D 0 && *cur !=3D terminator) { + while (*cur !=3D 0) { /* * 3 constructs are allowed: * - N : a single CPU number @@ -431,7 +423,7 @@ virBitmapParseSeparator(const char *str, virSkipSpaces(&cur); - if (*cur =3D=3D ',' || *cur =3D=3D 0 || *cur =3D=3D terminator) { + if (*cur =3D=3D ',' || *cur =3D=3D 0) { if (neg) { if (virBitmapClearBit(*bitmap, start) < 0) goto error; @@ -465,7 +457,7 @@ virBitmapParseSeparator(const char *str, cur++; virSkipSpaces(&cur); neg =3D false; - } else if (*cur =3D=3D 0 || *cur =3D=3D terminator) { + } else if (*cur =3D=3D 0) { break; } else { goto error; @@ -503,7 +495,7 @@ virBitmapParse(const char *str, virBitmap **bitmap, size_t bitmapSize) { - return virBitmapParseSeparator(str, '\0', bitmap, bitmapSize); + return virBitmapParseInternal(str, bitmap, bitmapSize); } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052566; cv=none; d=zohomail.com; s=zohoarc; b=XTUNuWfWTI9XT0yQ1bu+nPSaEailceac0/IHHYLNr/HEx6WsAosc1GwxHbWX5uGWU015H8PvvMcY2pBIbOKGN2Nmh/juNckip0XJRJau6Xl6x+ESv4gkPvjQjDh4VL0PaFZXPS/3wT0aLIJ2SvcU0eLESA515MbGAblA4nyc6sA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052566; 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=Q3d/F52FJzYrVQFaCwhWbnKUum7zLzNP4QLP9qYtKhg=; b=TWsUkgtN9AyRG9rapgKSolt4mnu9943SWGPKWCp5b8lD77lHi97edjWPm+xuPWbVQVzditFWDgGXs4WFs/TWOIGU47saunu8+kEh/IMEZY30l/AJlaXqjN/0pJFgd+/xvcPRKzg4S0d5QQxJn5YaaE0IJ+7I89qGLaSvsbXJuWs= 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 1639052566077179.55393286569245; Thu, 9 Dec 2021 04:22:46 -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-157-BWk334KVO_m45rTzNyQf4Q-1; Thu, 09 Dec 2021 07:22:32 -0500 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 34C92760C0; Thu, 9 Dec 2021 12:22:27 +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 143385ED2B; Thu, 9 Dec 2021 12:22:27 +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 D9AF21802E2A; Thu, 9 Dec 2021 12:22:26 +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 1B9CMPXl015664 for ; Thu, 9 Dec 2021 07:22:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7D9BA5ED31; Thu, 9 Dec 2021 12:22:25 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id D02A05ED27 for ; Thu, 9 Dec 2021 12:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052565; 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=Q3d/F52FJzYrVQFaCwhWbnKUum7zLzNP4QLP9qYtKhg=; b=d2z7odjRYJSteP0ne4TujJ8DPfTBpF0QkNPSEbafSGnNyt/ZCw4YgCp0SUz/u6M4bGInnK vqVIxbdF+gLvvx6IhmyaSqSjSwhFNKE9fDvOrh0eBIGj86dKYlQOhf2sMs48Z1jaxHl/QS G6S47aqcn8jEwDnysEvX7vYub5bomV0= X-MC-Unique: BWk334KVO_m45rTzNyQf4Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 26/36] virBitmapParseInternal: Allocate the bitmap in the caller Date: Thu, 9 Dec 2021 13:18:31 +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.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) X-ZM-MESSAGEID: 1639052567392100009 Content-Type: text/plain; charset="utf-8" In order to prepare for reuse of the function, move the allocation of the bitmap to the caller. Signed-off-by: Peter Krempa --- src/util/virbitmap.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 1aaefba133..4047870e04 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -366,8 +366,7 @@ virBitmapFormat(virBitmap *bitmap) /** * virBitmapParseInternal: * @str: points to a string representing a human-readable bitmap - * @bitmap: a bitmap created from @str - * @bitmapSize: the upper limit of num of bits in created bitmap + * @bitmap: a bitmap populated from @str * * This function is the counterpart of virBitmapFormat. This function crea= tes * a bitmap, in which bits are set according to the content of @str. @@ -380,8 +379,7 @@ virBitmapFormat(virBitmap *bitmap) */ static int virBitmapParseInternal(const char *str, - virBitmap **bitmap, - size_t bitmapSize) + virBitmap *bitmap) { bool neg =3D false; const char *cur =3D str; @@ -389,8 +387,6 @@ virBitmapParseInternal(const char *str, size_t i; int start, last; - *bitmap =3D virBitmapNew(bitmapSize); - if (!str) goto error; @@ -425,10 +421,10 @@ virBitmapParseInternal(const char *str, if (*cur =3D=3D ',' || *cur =3D=3D 0) { if (neg) { - if (virBitmapClearBit(*bitmap, start) < 0) + if (virBitmapClearBit(bitmap, start) < 0) goto error; } else { - if (virBitmapSetBit(*bitmap, start) < 0) + if (virBitmapSetBit(bitmap, start) < 0) goto error; } } else if (*cur =3D=3D '-') { @@ -446,7 +442,7 @@ virBitmapParseInternal(const char *str, cur =3D tmp; for (i =3D start; i <=3D last; i++) { - if (virBitmapSetBit(*bitmap, i) < 0) + if (virBitmapSetBit(bitmap, i) < 0) goto error; } @@ -469,8 +465,6 @@ virBitmapParseInternal(const char *str, error: virReportError(VIR_ERR_INVALID_ARG, _("Failed to parse bitmap '%s'"), str); - virBitmapFree(*bitmap); - *bitmap =3D NULL; return -1; } @@ -495,7 +489,14 @@ virBitmapParse(const char *str, virBitmap **bitmap, size_t bitmapSize) { - return virBitmapParseInternal(str, bitmap, bitmapSize); + g_autoptr(virBitmap) tmp =3D virBitmapNew(bitmapSize); + + if (virBitmapParseInternal(str, tmp) < 0) + return -1; + + *bitmap =3D g_steal_pointer(&tmp); + + return 0; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052558; cv=none; d=zohomail.com; s=zohoarc; b=iu1CGUKCIjOAOyuGd8qdyLsHdAvigzjURViqulrdzxPdt0c3oIfwxeBcdyZB1UhnoB0odd7KCFlwV+g1j/sj/3ys+pg5MphJRNnV6aek/N9PrQwX0TyQhvB6OxCUeOwvnTYNDohrwgVUJ/UBbqfDxGELWBJmVuN8J7gSYP4zngo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052558; 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=xKr95M0f+pgobKSVeIGucpLhPMQstfbdrVIgK9/3wSY=; b=eHiE8EU0SJGrh3WL/HUsX7CbA3/NOTolhzs/JQTlOy8eKsh6F5NSNpDo+33t/4+A4XqOrI0bQRWnmIWnedVLvc7SLkHVe4HMhkQA7Qq9XEV0qi2Cht91khGFWGCZ6/xhR33ICVD9PBhvUSCG1f6JBccZkUHIfeX43691uJuCDiE= 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 1639052558383366.4325894511552; Thu, 9 Dec 2021 04:22:38 -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-365-lhBauNq6O0SSBOI_e3s4Hg-1; Thu, 09 Dec 2021 07:22:33 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C6D8100C664; Thu, 9 Dec 2021 12:22:28 +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 1D16C60BF1; Thu, 9 Dec 2021 12:22:28 +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 E866C1802E2D; Thu, 9 Dec 2021 12:22:27 +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 1B9CMQRm015670 for ; Thu, 9 Dec 2021 07:22:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 90CF55ED2B; Thu, 9 Dec 2021 12:22:26 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5DCF5E24E for ; Thu, 9 Dec 2021 12:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052557; 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=xKr95M0f+pgobKSVeIGucpLhPMQstfbdrVIgK9/3wSY=; b=T/VH2/GIIFKukUXQgVQqGgnWYTSw8dC4wtRj8uFpCCl69WmVO7zrB6ytM8t3tgkJPj77fZ 2miCEZvFx6fiLv8f/hw4ydJuuxSNXbcDrkHrj+qh77lWJ7v/uHq52aB2PXNql/wpsNVdlL xRFaKXN8S/qV1dDETfpjKLl0YiKLmPs= X-MC-Unique: lhBauNq6O0SSBOI_e3s4Hg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 27/36] util: bitmap: Unify parsing of bitmaps Date: Thu, 9 Dec 2021 13:18:32 +0100 Message-Id: <93c4e1f90c18454c3dc7ca7ec286e3e325116bbd.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.12 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: 1639052558988100001 Content-Type: text/plain; charset="utf-8" There were two separate instances of string->virBitmap code: virBitmapParseInternal and virBitmapParseUnlimited. By adding a flag to switch to expanding APIs we can merge the two implementations into one. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virbitmap.c | 115 ++++++++++--------------------------------- 1 file changed, 26 insertions(+), 89 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 4047870e04..5b9204cbd7 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -367,6 +367,7 @@ virBitmapFormat(virBitmap *bitmap) * virBitmapParseInternal: * @str: points to a string representing a human-readable bitmap * @bitmap: a bitmap populated from @str + * @limited: Don't use self-expanding APIs, report error if bit exceeds bi= tmap size * * This function is the counterpart of virBitmapFormat. This function crea= tes * a bitmap, in which bits are set according to the content of @str. @@ -379,7 +380,8 @@ virBitmapFormat(virBitmap *bitmap) */ static int virBitmapParseInternal(const char *str, - virBitmap *bitmap) + virBitmap *bitmap, + bool limited) { bool neg =3D false; const char *cur =3D str; @@ -421,11 +423,19 @@ virBitmapParseInternal(const char *str, if (*cur =3D=3D ',' || *cur =3D=3D 0) { if (neg) { - if (virBitmapClearBit(bitmap, start) < 0) - goto error; + if (limited) { + if (virBitmapClearBit(bitmap, start) < 0) + goto error; + } else { + virBitmapClearBitExpand(bitmap, start); + } } else { - if (virBitmapSetBit(bitmap, start) < 0) - goto error; + if (limited) { + if (virBitmapSetBit(bitmap, start) < 0) + goto error; + } else { + virBitmapSetBitExpand(bitmap, start); + } } } else if (*cur =3D=3D '-') { if (neg) @@ -442,8 +452,12 @@ virBitmapParseInternal(const char *str, cur =3D tmp; for (i =3D start; i <=3D last; i++) { - if (virBitmapSetBit(bitmap, i) < 0) - goto error; + if (limited) { + if (virBitmapSetBit(bitmap, i) < 0) + goto error; + } else { + virBitmapSetBitExpand(bitmap, i); + } } virSkipSpaces(&cur); @@ -491,7 +505,7 @@ virBitmapParse(const char *str, { g_autoptr(virBitmap) tmp =3D virBitmapNew(bitmapSize); - if (virBitmapParseInternal(str, tmp) < 0) + if (virBitmapParseInternal(str, tmp, true) < 0) return -1; *bitmap =3D g_steal_pointer(&tmp); @@ -518,89 +532,12 @@ virBitmapParse(const char *str, virBitmap * virBitmapParseUnlimited(const char *str) { - virBitmap *bitmap =3D virBitmapNew(0); - bool neg =3D false; - const char *cur =3D str; - char *tmp; - size_t i; - int start, last; - - if (!str) - goto error; - - virSkipSpaces(&cur); - - if (*cur =3D=3D '\0') - goto error; - - while (*cur !=3D 0) { - /* - * 3 constructs are allowed: - * - N : a single CPU number - * - N-M : a range of CPU numbers with N < M - * - ^N : remove a single CPU number from the current set - */ - if (*cur =3D=3D '^') { - cur++; - neg =3D true; - } - - if (!g_ascii_isdigit(*cur)) - goto error; - - if (virStrToLong_i(cur, &tmp, 10, &start) < 0) - goto error; - if (start < 0) - goto error; - - cur =3D tmp; - - virSkipSpaces(&cur); + g_autoptr(virBitmap) tmp =3D virBitmapNew(0); - if (*cur =3D=3D ',' || *cur =3D=3D 0) { - if (neg) { - virBitmapClearBitExpand(bitmap, start); - } else { - virBitmapSetBitExpand(bitmap, start); - } - } else if (*cur =3D=3D '-') { - if (neg) - goto error; - - cur++; - virSkipSpaces(&cur); - - if (virStrToLong_i(cur, &tmp, 10, &last) < 0) - goto error; - if (last < start) - goto error; - - cur =3D tmp; - - for (i =3D start; i <=3D last; i++) - virBitmapSetBitExpand(bitmap, i); - - virSkipSpaces(&cur); - } - - if (*cur =3D=3D ',') { - cur++; - virSkipSpaces(&cur); - neg =3D false; - } else if (*cur =3D=3D 0) { - break; - } else { - goto error; - } - } - - return bitmap; + if (virBitmapParseInternal(str, tmp, false) < 0) + return NULL; - error: - virReportError(VIR_ERR_INVALID_ARG, - _("Failed to parse bitmap '%s'"), NULLSTR(str)); - virBitmapFree(bitmap); - return NULL; + return g_steal_pointer(&tmp); } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052585; cv=none; d=zohomail.com; s=zohoarc; b=ReY2cMzLUb6dzicK+sMjScWTKHiCxhVzB3TpCDmkg4XoJTrIY7Q0mdyYIOW9MoC11xSyoK2VjlwB/s6Z2ZsYeNYD7Pno+SKsjrS0zrbqGxc2o/6LwMo56NMlyoxj41WDOQ9S0d9BE5qCzsMiMVvXQHluIDhFRBkyEIgcEEyaD9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052585; 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=Grpp+CUDOLLg5DdOONHMkjZaHQp+mragLwfuMvIaEOE=; b=Zx30Z28K2qydwJUuikggC+gn6LKquezF1SNguOoBe1YovVMBOEGz0r+xVXzT7am3Hu9ffbvdpUJdFJ7ksH7M05FSj7kqqKTcGVNIhmBW/lwn7Ru8WvtBm8R/SDYRZla4E+KZvbZPO/4Lk4ItjA8tQJAY7GWBSGa0kQ82ArZoM14= 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 1639052585624736.1241649596802; Thu, 9 Dec 2021 04:23:05 -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-90-jQShryjaPUywptKudTjVVg-1; Thu, 09 Dec 2021 07:22:35 -0500 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 BC786802E6F; Thu, 9 Dec 2021 12:22:30 +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 6FFE75ED2D; Thu, 9 Dec 2021 12:22:30 +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 428FD4A700; Thu, 9 Dec 2021 12:22:30 +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 1B9CMR4O015682 for ; Thu, 9 Dec 2021 07:22:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9B57717CD9; Thu, 9 Dec 2021 12:22:27 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 072A05E26C for ; Thu, 9 Dec 2021 12:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052584; 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=Grpp+CUDOLLg5DdOONHMkjZaHQp+mragLwfuMvIaEOE=; b=OKvLZYuUoepBMOrS9bZ12Gzq2OyFFEk192RnwWXMWswte6L3cfkb3QEgtQZVotMnBpqlaQ BnmkB33ocb5FL+AaVQmCtpOGShUSt4GBoAfc/9l3RNm8KF3Ja1+3vzZX6R5SMxWT3in1lI xk8pcfLQq7cTvHz+BoDk9W5yPAS/2Nc= X-MC-Unique: jQShryjaPUywptKudTjVVg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 28/36] test_driver: Use automatic memory freeing for temporary virBitmaps Date: Thu, 9 Dec 2021 13:18:33 +0100 Message-Id: <8c80d2bb30e08c3f4b04bf81bf0bcd0195bb5df2.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.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) X-ZM-MESSAGEID: 1639052587606100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/test/test_driver.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7ad6e15402..995e63b004 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2826,7 +2826,7 @@ testDomainPinEmulator(virDomainPtr dom, { virDomainObj *vm =3D NULL; virDomainDef *def =3D NULL; - virBitmap *pcpumap =3D NULL; + g_autoptr(virBitmap) pcpumap =3D NULL; int ret =3D -1; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -2848,11 +2848,10 @@ testDomainPinEmulator(virDomainPtr dom, } virBitmapFree(def->cputune.emulatorpin); - def->cputune.emulatorpin =3D virBitmapNewCopy(pcpumap); + def->cputune.emulatorpin =3D g_steal_pointer(&pcpumap); ret =3D 0; cleanup: - virBitmapFree(pcpumap); virDomainObjEndAPI(&vm); return ret; } @@ -2868,7 +2867,7 @@ testDomainGetEmulatorPinInfo(virDomainPtr dom, virDomainObj *vm =3D NULL; virDomainDef *def =3D NULL; virBitmap *cpumask =3D NULL; - virBitmap *bitmap =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; int hostcpus; int ret =3D -1; @@ -2898,7 +2897,6 @@ testDomainGetEmulatorPinInfo(virDomainPtr dom, ret =3D 1; cleanup: virDomainObjEndAPI(&vm); - virBitmapFree(bitmap); return ret; } @@ -3049,7 +3047,7 @@ static int testDomainGetVcpus(virDomainPtr domain, int hostcpus; int ret =3D -1; unsigned long long statbase; - virBitmap *allcpumap =3D NULL; + g_autoptr(virBitmap) allcpumap =3D NULL; if (!(privdom =3D testDomObjFromDomain(domain))) return -1; @@ -3102,7 +3100,6 @@ static int testDomainGetVcpus(virDomainPtr domain, ret =3D maxinfo; cleanup: - virBitmapFree(allcpumap); virDomainObjEndAPI(&privdom); return ret; } @@ -3523,7 +3520,7 @@ testDomainSetNumaParameters(virDomainPtr dom, { virDomainObj *vm =3D NULL; virDomainDef *def =3D NULL; - virBitmap *nodeset =3D NULL; + g_autoptr(virBitmap) nodeset =3D NULL; virDomainNumatuneMemMode config_mode; bool live; size_t i; @@ -3590,7 +3587,6 @@ testDomainSetNumaParameters(virDomainPtr dom, ret =3D 0; cleanup: - virBitmapFree(nodeset); virDomainObjEndAPI(&vm); return ret; } @@ -9669,7 +9665,7 @@ testDomainPinIOThread(virDomainPtr dom, virDomainObj *vm; virDomainDef *def; virDomainIOThreadIDDef *iothrid; - virBitmap *cpumask =3D NULL; + g_autoptr(virBitmap) cpumask =3D NULL; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -9702,7 +9698,6 @@ testDomainPinIOThread(virDomainPtr dom, ret =3D 0; cleanup: - virBitmapFree(cpumask); virDomainObjEndAPI(&vm); return ret; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052560; cv=none; d=zohomail.com; s=zohoarc; b=g6ooOu7xdYU5410KAVpEnJVwSnud4FRYnG84DVFSTSzO8bhAVKHEiUhltA/W2vrfc65hof7bAZGZ/OUYxoJBBxPxzRWrfy0q+5P7nkA6PNZsdVlZo/UcWfBkdJJIZowC88u72jhynz3O/HbE+UKxDkZLHF75Zw3mw6Og4+sRcDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052560; 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=l1jGP92NdtscAddJ87h455Zeay1o1A5t3cilH0DzG94=; b=Aof1YG608ADPbrKPJxy/DHuNUhxYm2DVp94JoVwqR2BAUtE42v1efrTBfv27xA7XU35fl/6lBEIl8tprPVo5IDdY9ezKks655kDan9P6i/SE7xh4QTE7+8hcn433rmG/CqEog+3MCdnyyVBnOEl4EusA1VMPDqb3QvWbNEqbiDk= 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 1639052560448948.9214376119278; Thu, 9 Dec 2021 04:22:40 -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-215-DqJVPvivPoKVWghRRYMgUA-1; Thu, 09 Dec 2021 07:22:37 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC74D100C68D; Thu, 9 Dec 2021 12:22:30 +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 A8FB65D6CF; Thu, 9 Dec 2021 12:22:30 +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 771574A707; Thu, 9 Dec 2021 12:22:30 +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 1B9CMSxj015692 for ; Thu, 9 Dec 2021 07:22:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id A74BD17CD9; Thu, 9 Dec 2021 12:22:28 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A4B75E24E for ; Thu, 9 Dec 2021 12:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052559; 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=l1jGP92NdtscAddJ87h455Zeay1o1A5t3cilH0DzG94=; b=ax0w/7yGpypKddl2tJLugP1t+JOC5f0/KH7wekgbhZNZzOtRTmGC2BbFadxAfSRSNym3CR QyIWpevHulVdzruWOvg/6jp/KEFvHwucKW8JvnI6pg1meY3oBhETcEbxFj8HAO9xvFTc+V bc1gW9+2H6IeeD73fc4LVUpSIr4WdUk= X-MC-Unique: DqJVPvivPoKVWghRRYMgUA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 29/36] lxcSetCpusetTune: Refactor memory clearing Date: Thu, 9 Dec 2021 13:18:34 +0100 Message-Id: <23b9d134f4d718b2be44b5f977132775314caf98.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.15 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: 1639052561672100001 Content-Type: text/plain; charset="utf-8" Use automatic memory clearing for virBitmap and remove a reuse of a temporary string. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/lxc/lxc_native.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 972e9cdc15..e9b58cbd1a 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -926,32 +926,28 @@ lxcSetCpuTune(virDomainDef *def, virConf *properties) static int lxcSetCpusetTune(virDomainDef *def, virConf *properties) { - g_autofree char *value =3D NULL; - virBitmap *nodeset =3D NULL; + g_autofree char *cpus =3D NULL; + g_autofree char *mems =3D NULL; + g_autoptr(virBitmap) nodeset =3D NULL; if (virConfGetValueString(properties, "lxc.cgroup.cpuset.cpus", - &value) > 0) { - if (virBitmapParse(value, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) <= 0) + &cpus) > 0) { + if (virBitmapParse(cpus, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < = 0) return -1; def->placement_mode =3D VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC; - g_free(value); - value =3D NULL; } if (virConfGetValueString(properties, "lxc.cgroup.cpuset.mems", - &value) > 0) { - if (virBitmapParse(value, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) + &mems) > 0) { + if (virBitmapParse(mems, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) return -1; if (virDomainNumatuneSet(def->numa, def->placement_mode =3D=3D VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC, VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC, VIR_DOMAIN_NUMATUNE_MEM_STRICT, - nodeset) < 0) { - virBitmapFree(nodeset); + nodeset) < 0) return -1; - } - virBitmapFree(nodeset); } return 0; --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052563; cv=none; d=zohomail.com; s=zohoarc; b=K4f4Y0pfZHLmLHqnlc26K3+SYCIrxLyYT1WrqGSpwJnqV3JokfjwAalXaJ5ieXipP4BaKqFA+FN0J/TBF9kPWkBA9qfEKDaAg5ng80Ns4g8VNv7jbSlliH/DBPREljX17RXYHoDgYrJ0TG3Ieus5mGK2Zm+4bXj9lxt0dWjFLHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052563; 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=ZoB6++szfe3dxH5z1VNlnQZbiL432lPGghx8vafOxY0=; b=RNbOh7GqIdWvc7uLmiCNsqfcjhujnMqviCceEDY1vrGfoVxw0k37cscw1ehJOakLzQfopUqb2u4yZu2jG5PbhpKSdSipBecu5wO0zrGwK3QfrPTE4eoUAgxiJVvzN+fgLoVSDbSWXQSkGzXyMCn1JlwODVyFdYVyBfbGDn0TJr4= 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 1639052563157241.2457986998802; Thu, 9 Dec 2021 04:22:43 -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-308-68ppDSB3N06mjr3DMyz_pg-1; Thu, 09 Dec 2021 07:22:38 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2CED5802E65; Thu, 9 Dec 2021 12:22:34 +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 671765BE0A; Thu, 9 Dec 2021 12:22:33 +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 315981802E2A; Thu, 9 Dec 2021 12:22:33 +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 1B9CMTF7015706 for ; Thu, 9 Dec 2021 07:22:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id B51785E24E; Thu, 9 Dec 2021 12:22:29 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E60E5ED27 for ; Thu, 9 Dec 2021 12:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052562; 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=ZoB6++szfe3dxH5z1VNlnQZbiL432lPGghx8vafOxY0=; b=Yv/MIt/ZFyBKL6T5jFZa0jOvdTR81PHZAUAVOlyIowTnlrDFfcPIf9rSIfUt8Y3Qj8QX8V oHRUeSczTWhuA2dVsVlCGDBFQLLc7A3H/mF9aQIELNwJctjIgZo6PZJ1I0k+FBc0f70xUc GrWcQcKwK7dcbrnfkQkotVXLlpFf2TI= X-MC-Unique: 68ppDSB3N06mjr3DMyz_pg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 30/36] libxl_driver: Use automatic memory freeing for virBitmap Date: Thu, 9 Dec 2021 13:18:35 +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.15 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: 1639052564504100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libxl/libxl_driver.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 0b14b5093e..ef31f2cdcf 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -2416,7 +2416,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned in= t vcpu, libxlDriverPrivate *driver =3D dom->conn->privateData; libxlDriverConfig *cfg =3D libxlDriverConfigGet(driver); virDomainDef *targetDef =3D NULL; - virBitmap *pcpumap =3D NULL; + g_autoptr(virBitmap) pcpumap =3D NULL; virDomainVcpuDef *vcpuinfo; virDomainObj *vm; int ret =3D -1; @@ -2477,7 +2477,6 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned in= t vcpu, cleanup: virDomainObjEndAPI(&vm); - virBitmapFree(pcpumap); virObjectUnref(cfg); return ret; } @@ -4808,7 +4807,7 @@ libxlDomainGetNumaParameters(virDomainPtr dom, libxlDriverConfig *cfg =3D libxlDriverConfigGet(driver); virDomainObj *vm; libxl_bitmap nodemap; - virBitmap *nodes =3D NULL; + g_autoptr(virBitmap) nodes =3D NULL; int rc, ret =3D -1; size_t i, j; @@ -4907,7 +4906,6 @@ libxlDomainGetNumaParameters(virDomainPtr dom, ret =3D 0; cleanup: - virBitmapFree(nodes); libxl_bitmap_dispose(&nodemap); virDomainObjEndAPI(&vm); virObjectUnref(cfg); --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052563; cv=none; d=zohomail.com; s=zohoarc; b=LshEXoTAdkOW0NwJjU/Uai8aCde2g9+0Y3bIr/0FfeKJam2pSEaTY4NwjUv/5rG1Aw5B4MtjrcfHC1DheyAB5E84CKt4mFNsFN6yLBN+aX3MJvBGSy8W/gtYdus2BZ2WwJsgFDfdmwyHNtKTf/9gNcksIYKDYuzChJQKh6Yi3aA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052563; 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=UjM5pFAh+/gYDOJfT3l6aCZ2vimfCwliasE59oq3RiM=; b=AzkjY7c/IxxC6rFYd1G6f1tzqk0ky4hcfKlcCWULgJvdt3yA3ResxChGHz1zjrAo0uduBWB8GC7DwKzeBzwkhfMiVVXW41GXk+Z2ilNjsVdFzCut4Yioz/gwd5XDJn+b8xac2rOIGlaSPenQUGWYIKoQJzRddnJHaK/VismOKcM= 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 1639052563101421.80710281034476; Thu, 9 Dec 2021 04:22:43 -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-472-bjJrVF4lNTm1aewd7hxGOA-1; Thu, 09 Dec 2021 07:22:40 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C18B81CCCC; Thu, 9 Dec 2021 12:22:36 +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 0FA1F100E113; Thu, 9 Dec 2021 12:22:36 +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 D52934A708; Thu, 9 Dec 2021 12:22:35 +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 1B9CMUth015724 for ; Thu, 9 Dec 2021 07:22:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id C078917CD9; Thu, 9 Dec 2021 12:22:30 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20CA65E275 for ; Thu, 9 Dec 2021 12:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052562; 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=UjM5pFAh+/gYDOJfT3l6aCZ2vimfCwliasE59oq3RiM=; b=QFOTALdVs1jS0fmGb8CZRKbxC1/Xlh1nJN24VSuMuyRBbIVw08r9fBKDpZUkd5vhWujyHE 3juX3ehrDOofHjW4K2qg3nSwf5ygKhwDsxAEOOOrUVBDa1fyGanRSW0ehvTvooBKV+jqdk 4Sn12RyQBmebrVK/wSxjw1KthumEbBA= X-MC-Unique: bjJrVF4lNTm1aewd7hxGOA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 31/36] libxlDomainGetNumaParameters: Don't clear a freshly allocated bitmap Date: Thu, 9 Dec 2021 13:18:36 +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.84 on 10.5.11.22 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: 1639052564462100001 Content-Type: text/plain; charset="utf-8" The bitmap is allocated just above the explicit clear, so it's already empty. Signed-off-by: Peter Krempa --- src/libxl/libxl_driver.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index ef31f2cdcf..bc8598ea96 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4879,7 +4879,6 @@ libxlDomainGetNumaParameters(virDomainPtr dom, /* First, we convert libxl_bitmap into virBitmap. After that, * we format virBitmap as a string that can be returned. */ - virBitmapClearAll(nodes); libxl_for_each_set_bit(j, nodemap) { if (virBitmapSetBit(nodes, j)) { virReportError(VIR_ERR_INTERNAL_ERROR, --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052582; cv=none; d=zohomail.com; s=zohoarc; b=ZZ53n/19Z5wnaPnqRvCmMy49el6HlEqc4DnLmv/br9Q6EwXpZajqfxpacitxDLw0h+z5d1AOG86BLudB8f1VYKATVT65fAaFMc+nV9YjqAjItnYZZV1kSLGkOxsekzvfK9ZI2k+mqMoAzBDTicRn3eAEQ87IazPnV2m4POfJHmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052582; 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=/0GumRd/DWnZINN+IA9CvmZXIMQSw+VzWdKnOWt9Z+A=; b=SjGnKIY/y4Dv0gdOop0EbRDAevppbFNkXMk+yFiYqOFUqsFItwd1kIbxN0JJkcYbRZX4LAuUzfh0BXA70A+cJfYtw6LtUY2YJbpzbnlRvltfOOc2LGlW6JugAz58QtEAZRjwLXDpVYccASUud2K2xwkJKG/DFgus3ElQl6G2cj0= 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 16390525824281008.7504716603572; Thu, 9 Dec 2021 04:23:02 -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-599-iBc1ad-qOTuFoJp7hvp6lg-1; Thu, 09 Dec 2021 07:22:41 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7434D81CCBA; Thu, 9 Dec 2021 12:22:35 +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 54C83100EBAD; Thu, 9 Dec 2021 12:22:35 +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 EB3344A707; Thu, 9 Dec 2021 12:22:34 +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 1B9CMVTY015730 for ; Thu, 9 Dec 2021 07:22:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id CCB3B17CD9; Thu, 9 Dec 2021 12:22:31 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 383A55E24E for ; Thu, 9 Dec 2021 12:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052581; 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=/0GumRd/DWnZINN+IA9CvmZXIMQSw+VzWdKnOWt9Z+A=; b=aA6QSI2sp+VsW1Omw4fb4Mln2FWkNDJ6BMh2HJBkkUX+r0gyzf/Is6Tgs1EaNU78vKFDf6 LXcmwsUT1c2ye7hpMR4kvipPJtXDDsVVzAA66QEyqH0vDM8bCOBS84n2agHn6XPXJJEhUS Yz9B5GambppZk6/xPfkM/6QbSy9Sc14= X-MC-Unique: iBc1ad-qOTuFoJp7hvp6lg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 32/36] lxc_controller: Use automatic memory freeing for virBitmap Date: Thu, 9 Dec 2021 13:18:37 +0100 Message-Id: <09df8959068a5ed0f31f7df226b392dee3ebc6d3.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.84 on 10.5.11.22 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: 1639052582843100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/lxc/lxc_controller.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 039efcd7c7..ae1f090077 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -731,7 +731,7 @@ static int virLXCControllerSetupLoopDevices(virLXCContr= oller *ctrl) static int virLXCControllerSetupCpuAffinity(virLXCController *ctrl) { int hostcpus, maxcpu =3D CPU_SETSIZE; - virBitmap *cpumap; + g_autoptr(virBitmap) cpumap =3D NULL; virBitmap *cpumapToSet; VIR_DEBUG("Setting CPU affinity"); @@ -761,11 +761,8 @@ static int virLXCControllerSetupCpuAffinity(virLXCCont= roller *ctrl) * so use '0' to indicate our own process ID. No threads are * running at this point */ - if (virProcessSetAffinity(0 /* Self */, cpumapToSet, false) < 0) { - virBitmapFree(cpumap); + if (virProcessSetAffinity(0 /* Self */, cpumapToSet, false) < 0) return -1; - } - virBitmapFree(cpumap); return 0; } @@ -810,7 +807,7 @@ static int virLXCControllerGetNumadAdvice(virLXCControl= ler *ctrl, */ static int virLXCControllerSetupResourceLimits(virLXCController *ctrl) { - virBitmap *auto_nodeset =3D NULL; + g_autoptr(virBitmap) auto_nodeset =3D NULL; int ret =3D -1; virBitmap *nodeset =3D NULL; virDomainNumatuneMemMode mode; @@ -841,7 +838,6 @@ static int virLXCControllerSetupResourceLimits(virLXCCo= ntroller *ctrl) ret =3D 0; cleanup: - virBitmapFree(auto_nodeset); return ret; } @@ -852,7 +848,7 @@ static int virLXCControllerSetupResourceLimits(virLXCCo= ntroller *ctrl) */ static int virLXCControllerSetupCgroupLimits(virLXCController *ctrl) { - virBitmap *auto_nodeset =3D NULL; + g_autoptr(virBitmap) auto_nodeset =3D NULL; int ret =3D -1; virBitmap *nodeset =3D NULL; size_t i; @@ -884,7 +880,6 @@ static int virLXCControllerSetupCgroupLimits(virLXCCont= roller *ctrl) ret =3D 0; cleanup: - virBitmapFree(auto_nodeset); return ret; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052586; cv=none; d=zohomail.com; s=zohoarc; b=J41ZFzs2ikeUF7PrGG3VsDMHFbDQHD10nrBZhh2riZTmjMDvmi4Y3G0FJDoCcqRMy25QVSXb9XDYF78Hdrf9cHce3dSynSl4w9cz22qWxirFtnogTxQkmbKjlsviWIs2kaeLTjkZ9s2JPdoHiIsnawRqnEJvZ55aWwpJlrMTgtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052586; 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=q/YeSs9xNSlb9UICzbyzjhtTD4DGZ8s7Xi0vUE5Fd6A=; b=ZI5ztpNMF9rbN4jgi+x0bqQst39WPXTzYJqkHWYdETqH4w/7UazQ+qX0iePb/xO2mh/+H/Vp0ZsquZawj2K2aRJFCfVMYr691hX0UPQzbzJZh1AhtBIlX7qSYE6fmojlf0unxenl3Imm/0uo9GEZ7ZhtFiKidXgO2riye+hkfMI= 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 1639052586562219.70045190834674; Thu, 9 Dec 2021 04:23:06 -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-351-VJAqWD_kMgGrx1QAPpIFKA-1; Thu, 09 Dec 2021 07:22:43 -0500 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 E37AA81CCB8; Thu, 9 Dec 2021 12:22:37 +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 C77715E275; Thu, 9 Dec 2021 12:22:37 +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 9A77D1802E2A; Thu, 9 Dec 2021 12:22:37 +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 1B9CMWS1015738 for ; Thu, 9 Dec 2021 07:22:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id D729517CD9; Thu, 9 Dec 2021 12:22:32 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BBC45E24E for ; Thu, 9 Dec 2021 12:22:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052585; 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=q/YeSs9xNSlb9UICzbyzjhtTD4DGZ8s7Xi0vUE5Fd6A=; b=ScutQnHh3zFDJMTLSX/K+qflPB5RpUUJyeBprxk5sj9QuKQVsuLajVi5ZfLpjevpsPR2dy SJI1Nj0E3XQJqBeSd83BdmFOAx2Ses+TxGuxaNOYNLhZiXVgi4oz1rtzpnMkPRJXdIre0D hhMZMLsYGLydkMV4FeNJM0NfXEr5IWg= X-MC-Unique: VJAqWD_kMgGrx1QAPpIFKA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 33/36] virLXCControllerSetup(Resource|Cgroup)Limits: Refactor cleanup Date: Thu, 9 Dec 2021 13:18:38 +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.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) X-ZM-MESSAGEID: 1639052587722100003 Content-Type: text/plain; charset="utf-8" Remove the pointless cleanup sections. Signed-off-by: Peter Krempa --- src/lxc/lxc_controller.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index ae1f090077..c577d6a427 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -808,7 +808,6 @@ static int virLXCControllerGetNumadAdvice(virLXCControl= ler *ctrl, static int virLXCControllerSetupResourceLimits(virLXCController *ctrl) { g_autoptr(virBitmap) auto_nodeset =3D NULL; - int ret =3D -1; virBitmap *nodeset =3D NULL; virDomainNumatuneMemMode mode; @@ -824,21 +823,19 @@ static int virLXCControllerSetupResourceLimits(virLXC= Controller *ctrl) VIR_DEBUG("Setting up process resource limits"); if (virLXCControllerGetNumadAdvice(ctrl, &auto_nodeset) < 0) - goto cleanup; + return -1; nodeset =3D virDomainNumatuneGetNodeset(ctrl->def->numa, auto_= nodeset, -1); if (virNumaSetupMemoryPolicy(mode, nodeset) < 0) - goto cleanup; + return -1; } } if (virLXCControllerSetupCpuAffinity(ctrl) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - return ret; + return 0; } @@ -849,14 +846,13 @@ static int virLXCControllerSetupResourceLimits(virLXC= Controller *ctrl) static int virLXCControllerSetupCgroupLimits(virLXCController *ctrl) { g_autoptr(virBitmap) auto_nodeset =3D NULL; - int ret =3D -1; virBitmap *nodeset =3D NULL; size_t i; VIR_DEBUG("Setting up cgroup resource limits"); if (virLXCControllerGetNumadAdvice(ctrl, &auto_nodeset) < 0) - goto cleanup; + return -1; nodeset =3D virDomainNumatuneGetNodeset(ctrl->def->numa, auto_nodeset,= -1); @@ -864,23 +860,21 @@ static int virLXCControllerSetupCgroupLimits(virLXCCo= ntroller *ctrl) getpid(), ctrl->nnicindexes, ctrl->nicindexes))) - goto cleanup; + return -1; if (virCgroupAddMachineProcess(ctrl->cgroup, ctrl->initpid) < 0) - goto cleanup; + return -1; /* Add all qemu-nbd tasks to the cgroup */ for (i =3D 0; i < ctrl->nnbdpids; i++) { if (virCgroupAddMachineProcess(ctrl->cgroup, ctrl->nbdpids[i]) < 0) - goto cleanup; + return -1; } if (virLXCCgroupSetup(ctrl->def, ctrl->cgroup, nodeset) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - return ret; + return 0; } --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052570; cv=none; d=zohomail.com; s=zohoarc; b=W2gaQaCrIcB271ioKhpo+Wr/5YIpU71AUO2F+dPiWw2qcyO3tilI65OwNWkEyVK/7PZKwFfNH4PoQkhssF2z/12vufMb5oFunv59tZjvARX515C+Ig14+LYXmsFG/BnfNna+gHrPLPmPf7QIWCcDHxxkBIrjbd2RfLgdt6f1T+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052570; 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=mE+aR068QDHG5bh5NVbTjfJ9J9WSanxTqO0V1UBvmww=; b=gvUTLLuJwbwlv1KZFnkoIVLDomD9bYT8+FKPIGKYze2K6v9Dmb3n6lnI3q7OEMAMKaEW2qjNTNDvuWy+kwnNkpbOJrd9h8jxeoL8d7GLKDoZN3DQgUnBWtGpfofw8+X3AeRUEQj++uc3btM2ECpk1SNbaDe8aHRiqyGhD6a5yyY= 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 1639052570249628.2305463518745; Thu, 9 Dec 2021 04:22:50 -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-386-Vj4rOMhwM9CdbczJwDePcg-1; Thu, 09 Dec 2021 07:22:45 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD77581CCC7; Thu, 9 Dec 2021 12:22:40 +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 71E555D6D5; Thu, 9 Dec 2021 12:22:40 +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 35FBA1802E38; Thu, 9 Dec 2021 12:22:40 +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 1B9CMXrO015750 for ; Thu, 9 Dec 2021 07:22:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id E2BAB17DBA; Thu, 9 Dec 2021 12:22:33 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CE3217CD9 for ; Thu, 9 Dec 2021 12:22:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052569; 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=mE+aR068QDHG5bh5NVbTjfJ9J9WSanxTqO0V1UBvmww=; b=IB+pZ/nh/32fSq9AF8aJmD3XrBRolrmz5aqsrbbMPuD7XxMo6rzTLB4v6VtUpUaRxjx7CL osZB1M/OFfRdjLGUDf5kuXflC4PoEYCVgiPkr3lR12t1sn0g+1ODtjMCKxp0zayeA1sjN1 hdGAOtgWgR/Fyvp6NVzmwz1GDiC7dkg= X-MC-Unique: Vj4rOMhwM9CdbczJwDePcg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 34/36] virt-host-validate-common: Use automatic memory freeing for virBitmap Date: Thu, 9 Dec 2021 13:18:39 +0100 Message-Id: <6e4d615a7a2d865e3ba8476c132559d68a3d80a7.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.15 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: 1639052572280100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/virt-host-validate-common.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index aba1bdf6cf..647ed7b48b 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -330,7 +330,7 @@ int virHostValidateCGroupControllers(const char *hvname= G_GNUC_UNUSED, int virHostValidateIOMMU(const char *hvname, virHostValidateLevel level) { - virBitmap *flags; + g_autoptr(virBitmap) flags =3D NULL; struct stat sb; const char *bootarg =3D NULL; bool isAMD =3D false, isIntel =3D false; @@ -347,8 +347,6 @@ int virHostValidateIOMMU(const char *hvname, else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_= SVM)) isAMD =3D true; - virBitmapFree(flags); - if (isIntel) { if (access("/sys/firmware/acpi/tables/DMAR", F_OK) =3D=3D 0) { virHostMsgPass(); @@ -445,7 +443,7 @@ bool virHostKernelModuleIsLoaded(const char *module) int virHostValidateSecureGuests(const char *hvname, virHostValidateLevel level) { - virBitmap *flags; + g_autoptr(virBitmap) flags =3D NULL; bool hasFac158 =3D false; bool hasAMDSev =3D false; virArch arch =3D virArchFromHost(); @@ -460,8 +458,6 @@ int virHostValidateSecureGuests(const char *hvname, else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_= SEV)) hasAMDSev =3D true; - virBitmapFree(flags); - virHostMsgCheck(hvname, "%s", _("for secure guest support")); if (ARCH_IS_S390(arch)) { if (hasFac158) { --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052564; cv=none; d=zohomail.com; s=zohoarc; b=fr0vpfRa7fijasEOxrR1sHOYgGxOUdd2GJg94IEOSX3V2Z1gV3n7uXMZtXuzLX6n6zjz1amoANyNOdykVrlWSqwZSbnSlZzWy+u2j1BWoxFlv4GQ9OpO16dpkFA2y71O2K3+yBVn2JNug30847HtEAA/+nwKPGuqlHIDu5CWGJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052564; 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=YloaBTAyYDvmTp9jYdNoIDRJnTK4dSHnr89U1dfY7Qg=; b=c3Xm0wle/tOoGa+LQ8S+Ca3w3iMD3cPpBj2+nQIpN7b3jwNMIEGAvK570u3TliIXE4aoW8z8XWLeIqy5pDKRWPGxGHgXaVykgfNhAOS5zGJm+3cGxZ4iPmPow2GFpO38o1XicGh+Pt/JOr3n0TpA0d3d7sorJ4wWkcl1Xq8hOyM= 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 16390525647711020.7175408258756; Thu, 9 Dec 2021 04:22:44 -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-126-e-x-LgkfMomp06966WTpQw-1; Thu, 09 Dec 2021 07:22:42 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DD71E10168C6; Thu, 9 Dec 2021 12:22:37 +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 BF82F60BF1; Thu, 9 Dec 2021 12:22:37 +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 915CF4A70A; Thu, 9 Dec 2021 12:22:37 +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 1B9CMYLF015766 for ; Thu, 9 Dec 2021 07:22:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id EEBF917DBA; Thu, 9 Dec 2021 12:22:34 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FBCF17CD9 for ; Thu, 9 Dec 2021 12:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052563; 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=YloaBTAyYDvmTp9jYdNoIDRJnTK4dSHnr89U1dfY7Qg=; b=DHWME4FhEQ7ip3KprLFfBRkGtws2cPlFWYREEDJ4VM3pxFYNI5IZyg3qRlGpCi0quG23G4 VuWT9dB3h9iAn5ZZVzdMcsA7RiwOZ+SES41Ps80lfWr1TfLI4RfqKI9cQnBdz8FcN+KoXZ ufuy4zbo+Gs2DqJQDZuGRsdfYktoVxc= X-MC-Unique: e-x-LgkfMomp06966WTpQw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 35/36] virt-host-validate-qemu: Use automatic memory freeing for virBitmap Date: Thu, 9 Dec 2021 13:18:40 +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.12 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: 1639052566926100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/virt-host-validate-qemu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qem= u.c index d225a7e5c8..46ff1d2494 100644 --- a/tools/virt-host-validate-qemu.c +++ b/tools/virt-host-validate-qemu.c @@ -29,7 +29,7 @@ int virHostValidateQEMU(void) { - virBitmap *flags; + g_autoptr(virBitmap) flags =3D NULL; int ret =3D 0; bool hasHwVirt =3D false; bool hasVirtFlag =3D false; @@ -98,8 +98,6 @@ int virHostValidateQEMU(void) virHostMsgPass(); } - virBitmapFree(flags); - if (virHostValidateDeviceExists("QEMU", "/dev/vhost-net", VIR_HOST_VALIDATE_WARN, _("Load the 'vhost_net' module to impr= ove performance " --=20 2.31.1 From nobody Fri May 3 10:27:29 2024 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=1639052570; cv=none; d=zohomail.com; s=zohoarc; b=NRE74UXR1JJg4R/35Wj6CaycdkvQAM6VOaP8xJzDZMAkA3Hee7tPHqALXMIfBvwfBGRBF67pkgOhf8ekNWeg0ZiVSvtYhCGsXjy6BLcc3emOEmnkPyrF1AeywgpwTexxVn6kCJRGnKh5ynaQNVlVk9YB2yqRAERAfvj/i8I2+0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639052570; 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=xix/1u2Kjrj/mZi6veZlz9ucZdwP+XIcvaDIa0hRpfo=; b=WqTc2W0VUBG5balNhYXDq/yRxl6t1Zz5WytYHIiOjUPCRHmY0c39XZCJcYaegKFUxRe5rsGVM1B8ixtqjrx/g679uOls6cVhVueG0D4HTe+ndaB4l1WPKhPevsEjgS38jQypKNYvinG9dvY4oIRq4yE3kvqAxO8RmUuk5WDGlEo= 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 1639052570277292.2972848768603; Thu, 9 Dec 2021 04:22:50 -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-549-mdm1EsF8NxCWb_Sd-wJRtg-1; Thu, 09 Dec 2021 07:22:45 -0500 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 7FD5481CCCD; Thu, 9 Dec 2021 12:22:40 +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 6285C17CD9; Thu, 9 Dec 2021 12:22:40 +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 35E561802E37; Thu, 9 Dec 2021 12:22:40 +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 1B9CMahj015779 for ; Thu, 9 Dec 2021 07:22:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 137915E24E; Thu, 9 Dec 2021 12:22:36 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68B1D17CD9 for ; Thu, 9 Dec 2021 12:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639052569; 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=xix/1u2Kjrj/mZi6veZlz9ucZdwP+XIcvaDIa0hRpfo=; b=fOhUTwAjBQFG7gDDk1Mmr9cnO9hJkLbpJZfYREG1Di8Z2kyWvgaWYv/EBs4FD0QPFEo3Iw t9y15A7lUIxpPeavic9SwUs8UZ0ylcLVAXJsq3b2/XfP0YKI1Nus5ek3mxTyQNF5vW5je7 QehDbl06ja2W1U/3NzURmlUy/maxTr8= X-MC-Unique: mdm1EsF8NxCWb_Sd-wJRtg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 36/36] virHostCPUGetInfoPopulateLinux: Use automatic memory freeing for virBitmap Date: Thu, 9 Dec 2021 13:18:41 +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.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) X-ZM-MESSAGEID: 1639052572168100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virhostcpu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 83e3a5d0f1..54e2462a95 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -582,8 +582,8 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, unsigned int *cores, unsigned int *threads) { - virBitmap *present_cpus_map =3D NULL; - virBitmap *online_cpus_map =3D NULL; + g_autoptr(virBitmap) present_cpus_map =3D NULL; + g_autoptr(virBitmap) online_cpus_map =3D NULL; g_autoptr(DIR) nodedir =3D NULL; struct dirent *nodedirent =3D NULL; int nodecpus, nodecores, nodesockets, nodethreads, offline =3D 0; @@ -745,8 +745,6 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, ret =3D 0; cleanup: - virBitmapFree(present_cpus_map); - virBitmapFree(online_cpus_map); VIR_FREE(sysfs_nodedir); VIR_FREE(sysfs_cpudir); return ret; --=20 2.31.1