This function return value is invariant since 18f3771, so change
its type and remove all dependent checks.
Found by Linux Verification Center (linuxtesting.org) with Svace.
Reported-by: Pavel Nekrasov <p.nekrasov@fobos-nt.ru>
Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org>
---
src/hypervisor/virhostdev.c | 12 ++++--------
src/util/virscsi.c | 4 +---
src/util/virscsi.h | 2 +-
tests/virscsitest.c | 6 ++----
4 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index f8b5ab86e1..30a51507da 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -1212,11 +1212,9 @@ virHostdevUpdateActiveSCSIHostDevices(virHostdevManager *mgr,
return -1;
if ((tmp = virSCSIDeviceListFind(mgr->activeSCSIHostdevs, scsi))) {
- if (virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name) < 0)
- return -1;
+ virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name);
} else {
- if (virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name) < 0 ||
- virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0)
+ if (virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0)
return -1;
scsi = NULL;
}
@@ -1597,11 +1595,9 @@ virHostdevPrepareSCSIDevices(virHostdevManager *mgr,
goto error;
}
- if (virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name) < 0)
- goto error;
+ virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name);
} else {
- if (virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name) < 0)
- goto error;
+ virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name);
VIR_DEBUG("Adding %s to activeSCSIHostdevs", virSCSIDeviceGetName(scsi));
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 3d2c77e3b8..6899958e21 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -243,7 +243,7 @@ virSCSIDeviceFree(virSCSIDevice *dev)
g_free(dev);
}
-int
+void
virSCSIDeviceSetUsedBy(virSCSIDevice *dev,
const char *drvname,
const char *domname)
@@ -255,8 +255,6 @@ virSCSIDeviceSetUsedBy(virSCSIDevice *dev,
copy->domname = g_strdup(domname);
VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy);
-
- return 0;
}
bool
diff --git a/src/util/virscsi.h b/src/util/virscsi.h
index ec34303bdc..d76ee13bcc 100644
--- a/src/util/virscsi.h
+++ b/src/util/virscsi.h
@@ -50,7 +50,7 @@ virSCSIDevice *virSCSIDeviceNew(const char *sysfs_prefix,
bool shareable);
void virSCSIDeviceFree(virSCSIDevice *dev);
-int virSCSIDeviceSetUsedBy(virSCSIDevice *dev,
+void virSCSIDeviceSetUsedBy(virSCSIDevice *dev,
const char *drvname,
const char *domname);
bool virSCSIDeviceIsAvailable(virSCSIDevice *dev);
diff --git a/tests/virscsitest.c b/tests/virscsitest.c
index c96699e157..2c3b599c7a 100644
--- a/tests/virscsitest.c
+++ b/tests/virscsitest.c
@@ -87,14 +87,12 @@ test2(const void *data G_GNUC_UNUSED)
if (!virSCSIDeviceIsAvailable(dev))
goto cleanup;
- if (virSCSIDeviceSetUsedBy(dev, "QEMU", "fc18") < 0)
- goto cleanup;
+ virSCSIDeviceSetUsedBy(dev, "QEMU", "fc18");
if (virSCSIDeviceIsAvailable(dev))
goto cleanup;
- if (virSCSIDeviceSetUsedBy(dev, "QEMU", "fc20") < 0)
- goto cleanup;
+ virSCSIDeviceSetUsedBy(dev, "QEMU", "fc20");
if (virSCSIDeviceIsAvailable(dev))
goto cleanup;
--
2.42.2
On Thu, Nov 28, 2024 at 16:28:08 +0300, Alexander Kuznetsov wrote: > This function return value is invariant since 18f3771, so change > its type and remove all dependent checks. > > Found by Linux Verification Center (linuxtesting.org) with Svace. > > Reported-by: Pavel Nekrasov <p.nekrasov@fobos-nt.ru> > Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org> > --- > src/hypervisor/virhostdev.c | 12 ++++-------- > src/util/virscsi.c | 4 +--- > src/util/virscsi.h | 2 +- > tests/virscsitest.c | 6 ++---- > 4 files changed, 8 insertions(+), 16 deletions(-) > ... > diff --git a/src/util/virscsi.h b/src/util/virscsi.h > index ec34303bdc..d76ee13bcc 100644 > --- a/src/util/virscsi.h > +++ b/src/util/virscsi.h > @@ -50,7 +50,7 @@ virSCSIDevice *virSCSIDeviceNew(const char *sysfs_prefix, > bool shareable); > > void virSCSIDeviceFree(virSCSIDevice *dev); > -int virSCSIDeviceSetUsedBy(virSCSIDevice *dev, > +void virSCSIDeviceSetUsedBy(virSCSIDevice *dev, > const char *drvname, > const char *domname); Indentation error. > bool virSCSIDeviceIsAvailable(virSCSIDevice *dev); Jirka
On Thu, Nov 28, 2024 at 16:28:08 +0300, Alexander Kuznetsov wrote: > This function return value is invariant since 18f3771, so change > its type and remove all dependent checks. > > Found by Linux Verification Center (linuxtesting.org) with Svace. > > Reported-by: Pavel Nekrasov <p.nekrasov@fobos-nt.ru> > Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org> > --- > src/hypervisor/virhostdev.c | 12 ++++-------- > src/util/virscsi.c | 4 +--- > src/util/virscsi.h | 2 +- > tests/virscsitest.c | 6 ++---- > 4 files changed, 8 insertions(+), 16 deletions(-) > > diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c > index f8b5ab86e1..30a51507da 100644 > --- a/src/hypervisor/virhostdev.c > +++ b/src/hypervisor/virhostdev.c > @@ -1212,11 +1212,9 @@ virHostdevUpdateActiveSCSIHostDevices(virHostdevManager *mgr, > return -1; > > if ((tmp = virSCSIDeviceListFind(mgr->activeSCSIHostdevs, scsi))) { > - if (virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name) < 0) > - return -1; > + virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name); > } else { > - if (virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name) < 0 || > - virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0) > + if (virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0) Originally both SetUsedBy and ListAdd were called, but only ListAdd is called now. The call to virSCSIDeviceSetUsedBy is missing. > return -1; > scsi = NULL; > } The rest looks good. Jirka
© 2016 - 2024 Red Hat, Inc.