]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Change return type of virSCSIDeviceSetUsedBy to void
authorAlexander Kuznetsov <kuznetsovam@altlinux.org>
Mon, 16 Dec 2024 09:41:06 +0000 (12:41 +0300)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 16 Dec 2024 10:28:21 +0000 (11:28 +0100)
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>
src/hypervisor/virhostdev.c
src/util/virscsi.c
src/util/virscsi.h
tests/virscsitest.c

index f8b5ab86e18d1189785cb08f647cb51566531794..84c036e075d46db9b7e77191a2196db46f8d7302 100644 (file)
@@ -1212,11 +1212,10 @@ 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)
+        virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name);
+        if (virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0)
             return -1;
         scsi = NULL;
     }
@@ -1597,11 +1596,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));
 
index 3d2c77e3b8cbef0ea9a8803300241d36b299186d..6899958e21ed5dab5f1fad0cfe8a166179b5720c 100644 (file)
@@ -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
index ec34303bdc092139602761a9c633f873da29bd45..8d7c00160b674a3727121d02897e1b1d65ffb954 100644 (file)
@@ -50,9 +50,9 @@ virSCSIDevice *virSCSIDeviceNew(const char *sysfs_prefix,
                                   bool shareable);
 
 void virSCSIDeviceFree(virSCSIDevice *dev);
-int virSCSIDeviceSetUsedBy(virSCSIDevice *dev,
-                           const char *drvname,
-                           const char *domname);
+void virSCSIDeviceSetUsedBy(virSCSIDevice *dev,
+                            const char *drvname,
+                            const char *domname);
 bool virSCSIDeviceIsAvailable(virSCSIDevice *dev);
 const char *virSCSIDeviceGetName(virSCSIDevice *dev);
 const char *virSCSIDeviceGetPath(virSCSIDevice *dev);
index c96699e15744c19f7931148f2ceb08b300d003be..2c3b599c7abd0229322e392e6257194cf2bfc782 100644 (file)
@@ -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;