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 <artem.chernyshev(a)red-soft.ru>
Signed-off-by: Alexander Kuznetsov <kuznetsovam(a)altlinux.org>
---
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 = virProcessGetAffinity(iothreadinfo->iothread_id)))
goto error;
- if (virBitmapToData(map, &(iothreadinfo->cpumap),
- &(iothreadinfo->cpumaplen)) < 0) {
- goto error;
- }
+ virBitmapToData(map, &(iothreadinfo->cpumap),
&(iothreadinfo->cpumaplen));
/* Append to iothreadinfolist */
iothreadinfolist[niothreads] = 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 *targetDef,
cpumask = bitmap;
}
}
- if (virBitmapToData(cpumask, &info_ret[i]->cpumap,
- &info_ret[i]->cpumaplen) < 0)
- goto cleanup;
+ virBitmapToData(cpumask, &info_ret[i]->cpumap,
&info_ret[i]->cpumaplen);
}
*info = 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 = virProcessGetAffinity(iothreads[i]->thread_id)))
goto endjob;
- if (virBitmapToData(map, &info_ret[i]->cpumap,
&info_ret[i]->cpumaplen) < 0)
- goto endjob;
+ virBitmapToData(map, &info_ret[i]->cpumap,
&info_ret[i]->cpumaplen);
}
*info = 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 = len;
virBitmapToDataBuf(bitmap, *data, *dataLen);
-
- return 0;
}
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_NONNULL(1);
virBitmap *virBitmapNewData(const void *data, int len) ATTRIBUTE_NONNULL(1);
-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);
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 = virHostCPUGetOnlineBitmap()))
goto cleanup;
- if (cpumap && virBitmapToData(cpus, cpumap, &dummy) < 0)
- goto cleanup;
+ if (cpumap)
+ virBitmapToData(cpus, cpumap, &dummy);
if (online)
*online = virBitmapCountBits(cpus);
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));
- if (virBitmapToData(bitmap, &data2, &len2) < 0)
- return -1;
+ virBitmapToData(bitmap, &data2, &len2);
if (len2 != sizeof(data) ||
data2[0] != 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 = virBitmapParseUnlimited(onlineVcpuStr)))
goto cleanup;
- if (virBitmapToData(onlineVcpus, &onlineVcpumap, &dummy) < 0)
- goto cleanup;
+ virBitmapToData(onlineVcpus, &onlineVcpumap, &dummy);
if (enable) {
offlinableVcpuStr = vshGetTypedParamValue(ctl, ¶ms[2]);
@@ -803,8 +802,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl,
if (!(offlinableVcpus = virBitmapParseUnlimited(offlinableVcpuStr)))
goto cleanup;
- if (virBitmapToData(offlinableVcpus, &offlinableVcpumap, &dummy) <
0)
- goto cleanup;
+ virBitmapToData(offlinableVcpus, &offlinableVcpumap, &dummy);
lastcpu = virBitmapLastSetBit(offlinableVcpus);
cpulist = g_new0(char *, nvcpus - virBitmapCountBits(onlineVcpus) + 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,
}
}
- if (virBitmapToData(map, &cpumap, cpumaplen) < 0)
- return NULL;
+ virBitmapToData(map, &cpumap, cpumaplen);
return cpumap;
}
--
2.42.4