util: Change return type of virSCSIDeviceSetUsedBy to void

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>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Alexander Kuznetsov 2024-12-16 12:41:06 +03:00 committed by Jiri Denemark
parent ed8eec073f
commit 20afcd4b14
4 changed files with 11 additions and 18 deletions

View File

@ -1212,11 +1212,10 @@ virHostdevUpdateActiveSCSIHostDevices(virHostdevManager *mgr,
return -1; return -1;
if ((tmp = virSCSIDeviceListFind(mgr->activeSCSIHostdevs, scsi))) { if ((tmp = virSCSIDeviceListFind(mgr->activeSCSIHostdevs, scsi))) {
if (virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name) < 0) virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name);
return -1;
} else { } else {
if (virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name) < 0 || virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name);
virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0) if (virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0)
return -1; return -1;
scsi = NULL; scsi = NULL;
} }
@ -1597,11 +1596,9 @@ virHostdevPrepareSCSIDevices(virHostdevManager *mgr,
goto error; goto error;
} }
if (virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name) < 0) virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name);
goto error;
} else { } else {
if (virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name) < 0) virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name);
goto error;
VIR_DEBUG("Adding %s to activeSCSIHostdevs", virSCSIDeviceGetName(scsi)); VIR_DEBUG("Adding %s to activeSCSIHostdevs", virSCSIDeviceGetName(scsi));

View File

@ -243,7 +243,7 @@ virSCSIDeviceFree(virSCSIDevice *dev)
g_free(dev); g_free(dev);
} }
int void
virSCSIDeviceSetUsedBy(virSCSIDevice *dev, virSCSIDeviceSetUsedBy(virSCSIDevice *dev,
const char *drvname, const char *drvname,
const char *domname) const char *domname)
@ -255,8 +255,6 @@ virSCSIDeviceSetUsedBy(virSCSIDevice *dev,
copy->domname = g_strdup(domname); copy->domname = g_strdup(domname);
VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy); VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy);
return 0;
} }
bool bool

View File

@ -50,9 +50,9 @@ virSCSIDevice *virSCSIDeviceNew(const char *sysfs_prefix,
bool shareable); bool shareable);
void virSCSIDeviceFree(virSCSIDevice *dev); void virSCSIDeviceFree(virSCSIDevice *dev);
int virSCSIDeviceSetUsedBy(virSCSIDevice *dev, void virSCSIDeviceSetUsedBy(virSCSIDevice *dev,
const char *drvname, const char *drvname,
const char *domname); const char *domname);
bool virSCSIDeviceIsAvailable(virSCSIDevice *dev); bool virSCSIDeviceIsAvailable(virSCSIDevice *dev);
const char *virSCSIDeviceGetName(virSCSIDevice *dev); const char *virSCSIDeviceGetName(virSCSIDevice *dev);
const char *virSCSIDeviceGetPath(virSCSIDevice *dev); const char *virSCSIDeviceGetPath(virSCSIDevice *dev);

View File

@ -87,14 +87,12 @@ test2(const void *data G_GNUC_UNUSED)
if (!virSCSIDeviceIsAvailable(dev)) if (!virSCSIDeviceIsAvailable(dev))
goto cleanup; goto cleanup;
if (virSCSIDeviceSetUsedBy(dev, "QEMU", "fc18") < 0) virSCSIDeviceSetUsedBy(dev, "QEMU", "fc18");
goto cleanup;
if (virSCSIDeviceIsAvailable(dev)) if (virSCSIDeviceIsAvailable(dev))
goto cleanup; goto cleanup;
if (virSCSIDeviceSetUsedBy(dev, "QEMU", "fc20") < 0) virSCSIDeviceSetUsedBy(dev, "QEMU", "fc20");
goto cleanup;
if (virSCSIDeviceIsAvailable(dev)) if (virSCSIDeviceIsAvailable(dev))
goto cleanup; goto cleanup;