From nobody Wed May 6 08:17:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 174299036727624.877006052605452; Wed, 26 Mar 2025 04:59:27 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4A2DF1465; Wed, 26 Mar 2025 07:59:26 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 807A8146F; Wed, 26 Mar 2025 07:59:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B9B73129A; Wed, 26 Mar 2025 07:58:58 -0400 (EDT) Received: from air.basealt.ru (air.basealt.ru [193.43.8.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5A4851457 for ; Wed, 26 Mar 2025 07:58:57 -0400 (EDT) Received: from kuznetsovam-nb.office.basealt.ru (unknown [193.43.10.250]) (Authenticated sender: kuznetsovam) by air.basealt.ru (Postfix) with ESMTPSA id CDAC920004; Wed, 26 Mar 2025 14:58:53 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 From: Alexander Kuznetsov To: devel@lists.libvirt.org Subject: [PATCH] virbitmap: Change return type of virBitmapToData to void Date: Wed, 26 Mar 2025 14:58:02 +0300 Message-ID: <20250326115814.23142-1-kuznetsovam@altlinux.org> X-Mailer: git-send-email 2.42.4 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ULFFMM2JFU2MVY6N5I2472JG7GAAWAUY X-Message-ID-Hash: ULFFMM2JFU2MVY6N5I2472JG7GAAWAUY X-MailFrom: kuznetsovam@altlinux.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: nickel@altlinux.org, egori@altlinux.org, artem.chernyshev@red-soft.ru X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZM-MESSAGEID: 1742990372284019100 Content-Type: text/plain; charset="utf-8" This function return value is invariant since e59b8f9, so change its type and remove all dependent checks. Found by Linux Verification Center (linuxtesting.org) with Svace. Signed-off-by: Artem Chernyshev Signed-off-by: Alexander Kuznetsov Reviewed-by: Jiri Denemark --- src/ch/ch_monitor.c | 5 +---- src/hypervisor/domain_driver.c | 4 +--- src/qemu/qemu_driver.c | 3 +-- src/util/virbitmap.c | 6 +----- src/util/virbitmap.h | 2 +- src/util/virhostcpu.c | 4 ++-- tests/virbitmaptest.c | 3 +-- tools/virsh-completer-domain.c | 6 ++---- tools/virsh-domain.c | 3 +-- 9 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 0ba927a194..b772eec8a2 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -1196,10 +1196,7 @@ virCHMonitorGetIOThreads(virCHMonitor *mon, if (!(map =3D virProcessGetAffinity(iothreadinfo->iothread_id)= )) goto error; =20 - if (virBitmapToData(map, &(iothreadinfo->cpumap), - &(iothreadinfo->cpumaplen)) < 0) { - goto error; - } + virBitmapToData(map, &(iothreadinfo->cpumap), &(iothreadinfo->= cpumaplen)); =20 /* Append to iothreadinfolist */ iothreadinfolist[niothreads] =3D g_steal_pointer(&iothreadinfo= ); diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index e2a08d737e..35966a5a8d 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -652,9 +652,7 @@ virDomainDriverGetIOThreadsConfig(virDomainDef *targetD= ef, cpumask =3D bitmap; } } - if (virBitmapToData(cpumask, &info_ret[i]->cpumap, - &info_ret[i]->cpumaplen) < 0) - goto cleanup; + virBitmapToData(cpumask, &info_ret[i]->cpumap, &info_ret[i]->cpuma= plen); } =20 *info =3D g_steal_pointer(&info_ret); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6ce949dd07..59ba6cfbf3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4787,8 +4787,7 @@ qemuDomainGetIOThreadsLive(virDomainObj *vm, if (!(map =3D virProcessGetAffinity(iothreads[i]->thread_id))) goto endjob; =20 - if (virBitmapToData(map, &info_ret[i]->cpumap, &info_ret[i]->cpuma= plen) < 0) - goto endjob; + virBitmapToData(map, &info_ret[i]->cpumap, &info_ret[i]->cpumaplen= ); } =20 *info =3D g_steal_pointer(&info_ret); diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index e42f5b872c..8a3f33c806 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -637,10 +637,8 @@ virBitmapNewData(const void *data, * Convert a bitmap to a chunk of data containing bits information. * Data consists of sequential bytes, with lower bytes containing * lower bits. This function allocates @data. - * - * Returns 0 on success, -1 otherwise. */ -int +void virBitmapToData(virBitmap *bitmap, unsigned char **data, int *dataLen) @@ -656,8 +654,6 @@ virBitmapToData(virBitmap *bitmap, *dataLen =3D len; =20 virBitmapToDataBuf(bitmap, *data, *dataLen); - - return 0; } =20 =20 diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index a9f9d97fd0..a9c0a1a307 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -91,7 +91,7 @@ virBitmap *virBitmapNewCopy(virBitmap *src) ATTRIBUTE_NON= NULL(1); =20 virBitmap *virBitmapNewData(const void *data, int len) ATTRIBUTE_NONNULL(1= ); =20 -int virBitmapToData(virBitmap *bitmap, unsigned char **data, int *dataLen) +void virBitmapToData(virBitmap *bitmap, unsigned char **data, int *dataLen) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 void virBitmapToDataBuf(virBitmap *bitmap, unsigned char *data, size_t len) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 3b4a11effb..80819d83e6 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1110,8 +1110,8 @@ virHostCPUGetMap(unsigned char **cpumap, if (!(cpus =3D virHostCPUGetOnlineBitmap())) goto cleanup; =20 - if (cpumap && virBitmapToData(cpus, cpumap, &dummy) < 0) - goto cleanup; + if (cpumap) + virBitmapToData(cpus, cpumap, &dummy); if (online) *online =3D virBitmapCountBits(cpus); =20 diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 27b6c13114..709c62ab54 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -339,8 +339,7 @@ test5(const void *v G_GNUC_UNUSED) ignore_value(virBitmapSetBit(bitmap, 2)); ignore_value(virBitmapSetBit(bitmap, 15)); =20 - if (virBitmapToData(bitmap, &data2, &len2) < 0) - return -1; + virBitmapToData(bitmap, &data2, &len2); =20 if (len2 !=3D sizeof(data) || data2[0] !=3D 0x05 || diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 0a3a113dca..b020d87f49 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -794,8 +794,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl, if (!(onlineVcpus =3D virBitmapParseUnlimited(onlineVcpuStr))) goto cleanup; =20 - if (virBitmapToData(onlineVcpus, &onlineVcpumap, &dummy) < 0) - goto cleanup; + virBitmapToData(onlineVcpus, &onlineVcpumap, &dummy); =20 if (enable) { offlinableVcpuStr =3D vshGetTypedParamValue(ctl, ¶ms[2]); @@ -803,8 +802,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl, if (!(offlinableVcpus =3D virBitmapParseUnlimited(offlinableVc= puStr))) goto cleanup; =20 - if (virBitmapToData(offlinableVcpus, &offlinableVcpumap, &dumm= y) < 0) - goto cleanup; + virBitmapToData(offlinableVcpus, &offlinableVcpumap, &dummy); =20 lastcpu =3D virBitmapLastSetBit(offlinableVcpus); cpulist =3D g_new0(char *, nvcpus - virBitmapCountBits(onlineV= cpus) + 1); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index ceff6789d8..a2e30a0fa9 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7420,8 +7420,7 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen, } } =20 - if (virBitmapToData(map, &cpumap, cpumaplen) < 0) - return NULL; + virBitmapToData(map, &cpumap, cpumaplen); =20 return cpumap; } --=20 2.42.4