[PATCH] util: Change return type of functions that never fail to void

Alexander Kuznetsov posted 1 patch 4 weeks ago
There is a newer version of this series
src/hypervisor/virhostdev.c     | 21 +++++++--------------
src/logging/log_daemon.c        |  8 ++------
src/logging/log_daemon_config.c |  4 +---
src/logging/log_daemon_config.h |  2 +-
src/util/virpci.c               |  4 +---
src/util/virpci.h               |  2 +-
src/util/virscsi.c              |  4 +---
src/util/virscsi.h              |  2 +-
src/util/virscsivhost.c         |  6 ++----
src/util/virscsivhost.h         |  2 +-
tests/virscsitest.c             |  6 ++----
11 files changed, 20 insertions(+), 41 deletions(-)
[PATCH] util: Change return type of functions that never fail to void
Posted by Alexander Kuznetsov 4 weeks ago
These functions 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     | 21 +++++++--------------
 src/logging/log_daemon.c        |  8 ++------
 src/logging/log_daemon_config.c |  4 +---
 src/logging/log_daemon_config.h |  2 +-
 src/util/virpci.c               |  4 +---
 src/util/virpci.h               |  2 +-
 src/util/virscsi.c              |  4 +---
 src/util/virscsi.h              |  2 +-
 src/util/virscsivhost.c         |  6 ++----
 src/util/virscsivhost.h         |  2 +-
 tests/virscsitest.c             |  6 ++----
 11 files changed, 20 insertions(+), 41 deletions(-)

diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index db94a2e056..037842c8a1 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -1131,8 +1131,7 @@ virHostdevUpdateActivePCIDevices(virHostdevManager *mgr,
         if (!actual)
             continue;
 
-        if (virPCIDeviceSetUsedBy(actual, drv_name, dom_name) < 0)
-            goto cleanup;
+        virPCIDeviceSetUsedBy(actual, drv_name, dom_name);
 
         /* Setup the original states for the PCI device */
         virPCIDeviceSetUnbindFromStub(actual, virBitmapIsBitSet(orig, VIR_DOMAIN_HOSTDEV_PCI_ORIGSTATE_UNBIND));
@@ -1213,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;
     }
@@ -1598,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));
 
@@ -1671,8 +1666,7 @@ virHostdevPrepareSCSIVHostDevices(virHostdevManager *mgr,
         if (!(host = virSCSIVHostDeviceNew(hostsrc->wwpn)))
             return -1;
 
-        if (virSCSIVHostDeviceSetUsedBy(host, drv_name, dom_name) < 0)
-            return -1;
+        virSCSIVHostDeviceSetUsedBy(host, drv_name, dom_name);
 
         if (virSCSIVHostDeviceListAdd(list, host) < 0)
             return -1;
@@ -2480,8 +2474,7 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *hostdev_mgr,
 
         /* We must restore some attributes that were lost on daemon restart. */
         virPCIDeviceSetUnbindFromStub(actual, true);
-        if (virPCIDeviceSetUsedBy(actual, drv_name, dom_name) < 0)
-            goto rollback;
+        virPCIDeviceSetUsedBy(actual, drv_name, dom_name);
 
         if (virPCIDeviceListAddCopy(hostdev_mgr->activePCIHostdevs, actual) < 0)
             goto rollback;
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index daf7ef4b2f..5a9be4a44e 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -692,14 +692,10 @@ int main(int argc, char **argv) {
         exit(EXIT_FAILURE);
     }
 
-    /* No explicit config, so try and find a default one */
+    /* No explicit config, so find a default one */
     if (remote_config_file == NULL) {
         implicit_conf = true;
-        if (virLogDaemonConfigFilePath(privileged,
-                                       &remote_config_file) < 0) {
-            VIR_ERROR(_("Can't determine config path"));
-            exit(EXIT_FAILURE);
-        }
+        virLogDaemonConfigFilePath(privileged, &remote_config_file);
     }
 
     /* Read the config file if it exists */
diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_config.c
index 248bd927d3..60c424ad84 100644
--- a/src/logging/log_daemon_config.c
+++ b/src/logging/log_daemon_config.c
@@ -33,7 +33,7 @@
 VIR_LOG_INIT("logging.log_daemon_config");
 
 
-int
+void
 virLogDaemonConfigFilePath(bool privileged, char **configfile)
 {
     if (privileged) {
@@ -45,8 +45,6 @@ virLogDaemonConfigFilePath(bool privileged, char **configfile)
 
         *configfile = g_strdup_printf("%s/virtlogd.conf", configdir);
     }
-
-    return 0;
 }
 
 
diff --git a/src/logging/log_daemon_config.h b/src/logging/log_daemon_config.h
index 43922feedf..5c10cc50d7 100644
--- a/src/logging/log_daemon_config.h
+++ b/src/logging/log_daemon_config.h
@@ -39,7 +39,7 @@ struct _virLogDaemonConfig {
 };
 
 
-int virLogDaemonConfigFilePath(bool privileged, char **configfile);
+void virLogDaemonConfigFilePath(bool privileged, char **configfile);
 virLogDaemonConfig *virLogDaemonConfigNew(bool privileged);
 void virLogDaemonConfigFree(virLogDaemonConfig *data);
 int virLogDaemonConfigLoadFile(virLogDaemonConfig *data,
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 289c0b330b..90617e69c6 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2049,7 +2049,7 @@ virPCIDeviceSetReprobe(virPCIDevice *dev, bool reprobe)
     dev->reprobe = reprobe;
 }
 
-int
+void
 virPCIDeviceSetUsedBy(virPCIDevice *dev,
                       const char *drv_name,
                       const char *dom_name)
@@ -2058,8 +2058,6 @@ virPCIDeviceSetUsedBy(virPCIDevice *dev,
     VIR_FREE(dev->used_by_domname);
     dev->used_by_drvname = g_strdup(drv_name);
     dev->used_by_domname = g_strdup(dom_name);
-
-    return 0;
 }
 
 void
diff --git a/src/util/virpci.h b/src/util/virpci.h
index ba5e0ae6f1..c5dcf9d37f 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -136,7 +136,7 @@ void virPCIDeviceSetStubDriverName(virPCIDevice *dev,
                                    const char *driverName);
 const char *virPCIDeviceGetStubDriverName(virPCIDevice *dev);
 virPCIDeviceAddress *virPCIDeviceGetAddress(virPCIDevice *dev);
-int virPCIDeviceSetUsedBy(virPCIDevice *dev,
+void virPCIDeviceSetUsedBy(virPCIDevice *dev,
                           const char *drv_name,
                           const char *dom_name);
 void virPCIDeviceGetUsedBy(virPCIDevice *dev,
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/src/util/virscsivhost.c b/src/util/virscsivhost.c
index 15024d7106..05b89e58d6 100644
--- a/src/util/virscsivhost.c
+++ b/src/util/virscsivhost.c
@@ -193,7 +193,7 @@ virSCSIVHostDeviceListNew(void)
 }
 
 
-int
+void
 virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
                             const char *drvname,
                             const char *domname)
@@ -202,8 +202,6 @@ virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
     VIR_FREE(dev->used_by_domname);
     dev->used_by_drvname = g_strdup(drvname);
     dev->used_by_domname = g_strdup(domname);
-
-    return 0;
 }
 
 
@@ -214,7 +212,7 @@ virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevice *dev,
 {
     *drv_name = dev->used_by_drvname;
     *dom_name = dev->used_by_domname;
- }
+}
 
 
 int
diff --git a/src/util/virscsivhost.h b/src/util/virscsivhost.h
index a7299382db..caaac26328 100644
--- a/src/util/virscsivhost.h
+++ b/src/util/virscsivhost.h
@@ -50,7 +50,7 @@ void virSCSIVHostDeviceListDel(virSCSIVHostDeviceList *list,
                                virSCSIVHostDevice *dev);
 virSCSIVHostDeviceList *virSCSIVHostDeviceListNew(void);
 virSCSIVHostDevice *virSCSIVHostDeviceNew(const char *name);
-int virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
+void virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
                                 const char *drvname,
                                 const char *domname);
 void virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevice *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
Re: [PATCH] util: Change return type of functions that never fail to void
Posted by Peter Krempa 4 weeks ago
On Wed, Nov 27, 2024 at 18:41:57 +0300, Alexander Kuznetsov wrote:
> These functions 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>
> ---

Please change only one function per patch even when they were caused by
the same change. Collecting all of them in a single patch makes it a bit
hard to follow and goes against the 'minimal commits' philosophy.
[PATCH v2 0/4] util: Change return type of functions that never fail to void
Posted by Alexander Kuznetsov 3 weeks, 6 days ago
These functions return value is invariant since 18f3771, so change
its type and remove all dependent checks.

Best regards,
Alexander Kuznetsov

---

v2:
- One function per commit.

Alexander Kuznetsov (4):
  util: Change return type of virPCIDeviceSetUsedBy to void
  util: Change return type of virSCSIDeviceSetUsedBy to void
  util: Change return type of virSCSIVHostDeviceSetUsedBy to void
  logging: Change return type of virLogDaemonConfigFilePat to void

 src/hypervisor/virhostdev.c     | 21 +++++++--------------
 src/logging/log_daemon.c        |  8 ++------
 src/logging/log_daemon_config.c |  4 +---
 src/logging/log_daemon_config.h |  2 +-
 src/util/virpci.c               |  4 +---
 src/util/virpci.h               |  2 +-
 src/util/virscsi.c              |  4 +---
 src/util/virscsi.h              |  2 +-
 src/util/virscsivhost.c         |  6 ++----
 src/util/virscsivhost.h         |  2 +-
 tests/virscsitest.c             |  6 ++----
 11 files changed, 20 insertions(+), 41 deletions(-)

-- 
2.42.2
[PATCH v3 0/4] util: Change return type of functions that never fail to void
Posted by Alexander Kuznetsov 1 week, 3 days ago
These functions return value is invariant since 18f3771, so change
its type and remove all dependent checks.

Best regards,
Alexander Kuznetsov

---
v3:
- Fix indentation errors.
- 2: add missing virSCSIDeviceSetUsedBy call
- 3: remove non-relevant cosmetic fix

v2:
- One function per commit.

Alexander Kuznetsov (4):
  util: Change return type of virPCIDeviceSetUsedBy to void
  util: Change return type of virSCSIDeviceSetUsedBy to void
  util: Change return type of virSCSIVHostDeviceSetUsedBy to void
  logging: Change return type of virLogDaemonConfigFilePat to void

 src/hypervisor/virhostdev.c     | 22 ++++++++--------------
 src/logging/log_daemon.c        |  8 ++------
 src/logging/log_daemon_config.c |  4 +---
 src/logging/log_daemon_config.h |  2 +-
 src/util/virpci.c               |  4 +---
 src/util/virpci.h               |  6 +++---
 src/util/virscsi.c              |  4 +---
 src/util/virscsi.h              |  6 +++---
 src/util/virscsivhost.c         |  4 +---
 src/util/virscsivhost.h         |  6 +++---
 tests/virscsitest.c             |  6 ++----
 11 files changed, 26 insertions(+), 46 deletions(-)

-- 
2.42.2
Re: [PATCH v3 0/4] util: Change return type of functions that never fail to void
Posted by Jiri Denemark 1 week, 3 days ago
On Mon, Dec 16, 2024 at 12:41:04 +0300, Alexander Kuznetsov wrote:
> These functions return value is invariant since 18f3771, so change
> its type and remove all dependent checks.
> 
> Best regards,
> Alexander Kuznetsov
> 
> ---
> v3:
> - Fix indentation errors.
> - 2: add missing virSCSIDeviceSetUsedBy call
> - 3: remove non-relevant cosmetic fix
> 
> v2:
> - One function per commit.
> 
> Alexander Kuznetsov (4):
>   util: Change return type of virPCIDeviceSetUsedBy to void
>   util: Change return type of virSCSIDeviceSetUsedBy to void
>   util: Change return type of virSCSIVHostDeviceSetUsedBy to void
>   logging: Change return type of virLogDaemonConfigFilePat to void
> 
>  src/hypervisor/virhostdev.c     | 22 ++++++++--------------
>  src/logging/log_daemon.c        |  8 ++------
>  src/logging/log_daemon_config.c |  4 +---
>  src/logging/log_daemon_config.h |  2 +-
>  src/util/virpci.c               |  4 +---
>  src/util/virpci.h               |  6 +++---
>  src/util/virscsi.c              |  4 +---
>  src/util/virscsi.h              |  6 +++---
>  src/util/virscsivhost.c         |  4 +---
>  src/util/virscsivhost.h         |  6 +++---
>  tests/virscsitest.c             |  6 ++----
>  11 files changed, 26 insertions(+), 46 deletions(-)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

and pushed. Thanks.
[PATCH v3 1/4] util: Change return type of virPCIDeviceSetUsedBy to void
Posted by Alexander Kuznetsov 1 week, 3 days ago
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 | 6 ++----
 src/util/virpci.c           | 4 +---
 src/util/virpci.h           | 6 +++---
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index db94a2e056..f8b5ab86e1 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -1131,8 +1131,7 @@ virHostdevUpdateActivePCIDevices(virHostdevManager *mgr,
         if (!actual)
             continue;
 
-        if (virPCIDeviceSetUsedBy(actual, drv_name, dom_name) < 0)
-            goto cleanup;
+        virPCIDeviceSetUsedBy(actual, drv_name, dom_name);
 
         /* Setup the original states for the PCI device */
         virPCIDeviceSetUnbindFromStub(actual, virBitmapIsBitSet(orig, VIR_DOMAIN_HOSTDEV_PCI_ORIGSTATE_UNBIND));
@@ -2480,8 +2479,7 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *hostdev_mgr,
 
         /* We must restore some attributes that were lost on daemon restart. */
         virPCIDeviceSetUnbindFromStub(actual, true);
-        if (virPCIDeviceSetUsedBy(actual, drv_name, dom_name) < 0)
-            goto rollback;
+        virPCIDeviceSetUsedBy(actual, drv_name, dom_name);
 
         if (virPCIDeviceListAddCopy(hostdev_mgr->activePCIHostdevs, actual) < 0)
             goto rollback;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 289c0b330b..90617e69c6 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2049,7 +2049,7 @@ virPCIDeviceSetReprobe(virPCIDevice *dev, bool reprobe)
     dev->reprobe = reprobe;
 }
 
-int
+void
 virPCIDeviceSetUsedBy(virPCIDevice *dev,
                       const char *drv_name,
                       const char *dom_name)
@@ -2058,8 +2058,6 @@ virPCIDeviceSetUsedBy(virPCIDevice *dev,
     VIR_FREE(dev->used_by_domname);
     dev->used_by_drvname = g_strdup(drv_name);
     dev->used_by_domname = g_strdup(dom_name);
-
-    return 0;
 }
 
 void
diff --git a/src/util/virpci.h b/src/util/virpci.h
index ba5e0ae6f1..4409864057 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -136,9 +136,9 @@ void virPCIDeviceSetStubDriverName(virPCIDevice *dev,
                                    const char *driverName);
 const char *virPCIDeviceGetStubDriverName(virPCIDevice *dev);
 virPCIDeviceAddress *virPCIDeviceGetAddress(virPCIDevice *dev);
-int virPCIDeviceSetUsedBy(virPCIDevice *dev,
-                          const char *drv_name,
-                          const char *dom_name);
+void virPCIDeviceSetUsedBy(virPCIDevice *dev,
+                           const char *drv_name,
+                           const char *dom_name);
 void virPCIDeviceGetUsedBy(virPCIDevice *dev,
                            const char **drv_name,
                            const char **dom_name);
-- 
2.42.2
[PATCH v3 2/4] util: Change return type of virSCSIDeviceSetUsedBy to void
Posted by Alexander Kuznetsov 1 week, 3 days ago
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 | 13 +++++--------
 src/util/virscsi.c          |  4 +---
 src/util/virscsi.h          |  6 +++---
 tests/virscsitest.c         |  6 ++----
 4 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index f8b5ab86e1..84c036e075 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -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));
 
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..8d7c00160b 100644
--- a/src/util/virscsi.h
+++ b/src/util/virscsi.h
@@ -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);
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
[PATCH v3 3/4] util: Change return type of virSCSIVHostDeviceSetUsedBy to void
Posted by Alexander Kuznetsov 1 week, 3 days ago
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 | 3 +--
 src/util/virscsivhost.c     | 4 +---
 src/util/virscsivhost.h     | 6 +++---
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index 84c036e075..0a1d8500d4 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -1667,8 +1667,7 @@ virHostdevPrepareSCSIVHostDevices(virHostdevManager *mgr,
         if (!(host = virSCSIVHostDeviceNew(hostsrc->wwpn)))
             return -1;
 
-        if (virSCSIVHostDeviceSetUsedBy(host, drv_name, dom_name) < 0)
-            return -1;
+        virSCSIVHostDeviceSetUsedBy(host, drv_name, dom_name);
 
         if (virSCSIVHostDeviceListAdd(list, host) < 0)
             return -1;
diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
index 15024d7106..6934fd574b 100644
--- a/src/util/virscsivhost.c
+++ b/src/util/virscsivhost.c
@@ -193,7 +193,7 @@ virSCSIVHostDeviceListNew(void)
 }
 
 
-int
+void
 virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
                             const char *drvname,
                             const char *domname)
@@ -202,8 +202,6 @@ virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
     VIR_FREE(dev->used_by_domname);
     dev->used_by_drvname = g_strdup(drvname);
     dev->used_by_domname = g_strdup(domname);
-
-    return 0;
 }
 
 
diff --git a/src/util/virscsivhost.h b/src/util/virscsivhost.h
index a7299382db..48b5fdec78 100644
--- a/src/util/virscsivhost.h
+++ b/src/util/virscsivhost.h
@@ -50,9 +50,9 @@ void virSCSIVHostDeviceListDel(virSCSIVHostDeviceList *list,
                                virSCSIVHostDevice *dev);
 virSCSIVHostDeviceList *virSCSIVHostDeviceListNew(void);
 virSCSIVHostDevice *virSCSIVHostDeviceNew(const char *name);
-int virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
-                                const char *drvname,
-                                const char *domname);
+void virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
+                                 const char *drvname,
+                                 const char *domname);
 void virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevice *dev,
                                  const char **drv_name,
                                  const char **dom_name);
-- 
2.42.2
[PATCH v3 4/4] logging: Change return type of virLogDaemonConfigFilePat to void
Posted by Alexander Kuznetsov 1 week, 3 days ago
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/logging/log_daemon.c        | 8 ++------
 src/logging/log_daemon_config.c | 4 +---
 src/logging/log_daemon_config.h | 2 +-
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index daf7ef4b2f..5a9be4a44e 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -692,14 +692,10 @@ int main(int argc, char **argv) {
         exit(EXIT_FAILURE);
     }
 
-    /* No explicit config, so try and find a default one */
+    /* No explicit config, so find a default one */
     if (remote_config_file == NULL) {
         implicit_conf = true;
-        if (virLogDaemonConfigFilePath(privileged,
-                                       &remote_config_file) < 0) {
-            VIR_ERROR(_("Can't determine config path"));
-            exit(EXIT_FAILURE);
-        }
+        virLogDaemonConfigFilePath(privileged, &remote_config_file);
     }
 
     /* Read the config file if it exists */
diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_config.c
index 248bd927d3..60c424ad84 100644
--- a/src/logging/log_daemon_config.c
+++ b/src/logging/log_daemon_config.c
@@ -33,7 +33,7 @@
 VIR_LOG_INIT("logging.log_daemon_config");
 
 
-int
+void
 virLogDaemonConfigFilePath(bool privileged, char **configfile)
 {
     if (privileged) {
@@ -45,8 +45,6 @@ virLogDaemonConfigFilePath(bool privileged, char **configfile)
 
         *configfile = g_strdup_printf("%s/virtlogd.conf", configdir);
     }
-
-    return 0;
 }
 
 
diff --git a/src/logging/log_daemon_config.h b/src/logging/log_daemon_config.h
index 43922feedf..5c10cc50d7 100644
--- a/src/logging/log_daemon_config.h
+++ b/src/logging/log_daemon_config.h
@@ -39,7 +39,7 @@ struct _virLogDaemonConfig {
 };
 
 
-int virLogDaemonConfigFilePath(bool privileged, char **configfile);
+void virLogDaemonConfigFilePath(bool privileged, char **configfile);
 virLogDaemonConfig *virLogDaemonConfigNew(bool privileged);
 void virLogDaemonConfigFree(virLogDaemonConfig *data);
 int virLogDaemonConfigLoadFile(virLogDaemonConfig *data,
-- 
2.42.2
Re: [PATCH v2 0/4] util: Change return type of functions that never fail to void
Posted by Alexander Kuznetsov 1 week, 5 days ago
Submit patches guideline recommends to ping if there is no response for more than a week,
so I kindly remind about these and neighboring cosmetic fixes :)

--
Best regards,
Alexander Kuznetsov
[PATCH v2 1/4] util: Change return type of virPCIDeviceSetUsedBy to void
Posted by Alexander Kuznetsov 3 weeks, 6 days ago
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 | 6 ++----
 src/util/virpci.c           | 4 +---
 src/util/virpci.h           | 2 +-
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index db94a2e056..f8b5ab86e1 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -1131,8 +1131,7 @@ virHostdevUpdateActivePCIDevices(virHostdevManager *mgr,
         if (!actual)
             continue;
 
-        if (virPCIDeviceSetUsedBy(actual, drv_name, dom_name) < 0)
-            goto cleanup;
+        virPCIDeviceSetUsedBy(actual, drv_name, dom_name);
 
         /* Setup the original states for the PCI device */
         virPCIDeviceSetUnbindFromStub(actual, virBitmapIsBitSet(orig, VIR_DOMAIN_HOSTDEV_PCI_ORIGSTATE_UNBIND));
@@ -2480,8 +2479,7 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *hostdev_mgr,
 
         /* We must restore some attributes that were lost on daemon restart. */
         virPCIDeviceSetUnbindFromStub(actual, true);
-        if (virPCIDeviceSetUsedBy(actual, drv_name, dom_name) < 0)
-            goto rollback;
+        virPCIDeviceSetUsedBy(actual, drv_name, dom_name);
 
         if (virPCIDeviceListAddCopy(hostdev_mgr->activePCIHostdevs, actual) < 0)
             goto rollback;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 289c0b330b..90617e69c6 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2049,7 +2049,7 @@ virPCIDeviceSetReprobe(virPCIDevice *dev, bool reprobe)
     dev->reprobe = reprobe;
 }
 
-int
+void
 virPCIDeviceSetUsedBy(virPCIDevice *dev,
                       const char *drv_name,
                       const char *dom_name)
@@ -2058,8 +2058,6 @@ virPCIDeviceSetUsedBy(virPCIDevice *dev,
     VIR_FREE(dev->used_by_domname);
     dev->used_by_drvname = g_strdup(drv_name);
     dev->used_by_domname = g_strdup(dom_name);
-
-    return 0;
 }
 
 void
diff --git a/src/util/virpci.h b/src/util/virpci.h
index ba5e0ae6f1..c5dcf9d37f 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -136,7 +136,7 @@ void virPCIDeviceSetStubDriverName(virPCIDevice *dev,
                                    const char *driverName);
 const char *virPCIDeviceGetStubDriverName(virPCIDevice *dev);
 virPCIDeviceAddress *virPCIDeviceGetAddress(virPCIDevice *dev);
-int virPCIDeviceSetUsedBy(virPCIDevice *dev,
+void virPCIDeviceSetUsedBy(virPCIDevice *dev,
                           const char *drv_name,
                           const char *dom_name);
 void virPCIDeviceGetUsedBy(virPCIDevice *dev,
-- 
2.42.2
Re: [PATCH v2 1/4] util: Change return type of virPCIDeviceSetUsedBy to void
Posted by Jiri Denemark 1 week, 5 days ago
On Thu, Nov 28, 2024 at 16:28:07 +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 | 6 ++----
>  src/util/virpci.c           | 4 +---
>  src/util/virpci.h           | 2 +-
>  3 files changed, 4 insertions(+), 8 deletions(-)
> 
...
> diff --git a/src/util/virpci.h b/src/util/virpci.h
> index ba5e0ae6f1..c5dcf9d37f 100644
> --- a/src/util/virpci.h
> +++ b/src/util/virpci.h
> @@ -136,7 +136,7 @@ void virPCIDeviceSetStubDriverName(virPCIDevice *dev,
>                                     const char *driverName);
>  const char *virPCIDeviceGetStubDriverName(virPCIDevice *dev);
>  virPCIDeviceAddress *virPCIDeviceGetAddress(virPCIDevice *dev);
> -int virPCIDeviceSetUsedBy(virPCIDevice *dev,
> +void virPCIDeviceSetUsedBy(virPCIDevice *dev,
>                            const char *drv_name,
>                            const char *dom_name);

Indentation error in the two lines above. "void" is one character longes
then "int".

Jirka
Re: [PATCH v2 1/4] util: Change return type of virPCIDeviceSetUsedBy to void
Posted by Alexander Kuznetsov 1 week, 5 days ago
13.12.2024 18:02, Jiri Denemark пишет:
> Indentation error in the two lines above. "void" is one character longes
> then "int".
>
> Jirka
Thanks for your patience!

This is my first experience of sending a set of patches, so could you tell me
what I should do with Reviewed-by tag when sending v3, since 2 patches have it,
and 2 patches don't. Should I add it to my commit message to these 2 patches?
"Submit patches" wasn't clear at this point, so I wanted to clarify

Thanks again for your time and patience!

-- 
Best regards,
Alexander Kuznetsov
Re: [PATCH v2 1/4] util: Change return type of virPCIDeviceSetUsedBy to void
Posted by Jiri Denemark 1 week, 5 days ago
On Fri, Dec 13, 2024 at 18:28:38 +0300, Alexander Kuznetsov wrote:
> 
> 13.12.2024 18:02, Jiri Denemark пишет:
> > Indentation error in the two lines above. "void" is one character longes
> > then "int".
> >
> > Jirka
> Thanks for your patience!
> 
> This is my first experience of sending a set of patches, so could you tell me
> what I should do with Reviewed-by tag when sending v3, since 2 patches have it,
> and 2 patches don't. Should I add it to my commit message to these 2 patches?
> "Submit patches" wasn't clear at this point, so I wanted to clarify

Yes, you add them to your patches when sending a new version of the
series. Unless you realize you have to make significant changes and need
the previously acked patches reviewed again, in which case you would not
add the reviewed-by line to the patch even if it was included in the
review.

Jirka
Re: [PATCH v2 1/4] util: Change return type of virPCIDeviceSetUsedBy to void
Posted by Jiri Denemark 1 week, 5 days ago
On Thu, Nov 28, 2024 at 16:28:07 +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 | 6 ++----
>  src/util/virpci.c           | 4 +---
>  src/util/virpci.h           | 2 +-
>  3 files changed, 4 insertions(+), 8 deletions(-)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
[PATCH v2 2/4] util: Change return type of virSCSIDeviceSetUsedBy to void
Posted by Alexander Kuznetsov 3 weeks, 6 days ago
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
Re: [PATCH v2 2/4] util: Change return type of virSCSIDeviceSetUsedBy to void
Posted by Jiri Denemark 1 week, 5 days ago
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
Re: [PATCH v2 2/4] util: Change return type of virSCSIDeviceSetUsedBy to void
Posted by Jiri Denemark 1 week, 5 days ago
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
[PATCH v2 3/4] util: Change return type of virSCSIVHostDeviceSetUsedBy to void
Posted by Alexander Kuznetsov 3 weeks, 6 days ago
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 | 3 +--
 src/util/virscsivhost.c     | 6 ++----
 src/util/virscsivhost.h     | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index 30a51507da..037842c8a1 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -1666,8 +1666,7 @@ virHostdevPrepareSCSIVHostDevices(virHostdevManager *mgr,
         if (!(host = virSCSIVHostDeviceNew(hostsrc->wwpn)))
             return -1;
 
-        if (virSCSIVHostDeviceSetUsedBy(host, drv_name, dom_name) < 0)
-            return -1;
+        virSCSIVHostDeviceSetUsedBy(host, drv_name, dom_name);
 
         if (virSCSIVHostDeviceListAdd(list, host) < 0)
             return -1;
diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
index 15024d7106..05b89e58d6 100644
--- a/src/util/virscsivhost.c
+++ b/src/util/virscsivhost.c
@@ -193,7 +193,7 @@ virSCSIVHostDeviceListNew(void)
 }
 
 
-int
+void
 virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
                             const char *drvname,
                             const char *domname)
@@ -202,8 +202,6 @@ virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
     VIR_FREE(dev->used_by_domname);
     dev->used_by_drvname = g_strdup(drvname);
     dev->used_by_domname = g_strdup(domname);
-
-    return 0;
 }
 
 
@@ -214,7 +212,7 @@ virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevice *dev,
 {
     *drv_name = dev->used_by_drvname;
     *dom_name = dev->used_by_domname;
- }
+}
 
 
 int
diff --git a/src/util/virscsivhost.h b/src/util/virscsivhost.h
index a7299382db..caaac26328 100644
--- a/src/util/virscsivhost.h
+++ b/src/util/virscsivhost.h
@@ -50,7 +50,7 @@ void virSCSIVHostDeviceListDel(virSCSIVHostDeviceList *list,
                                virSCSIVHostDevice *dev);
 virSCSIVHostDeviceList *virSCSIVHostDeviceListNew(void);
 virSCSIVHostDevice *virSCSIVHostDeviceNew(const char *name);
-int virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
+void virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
                                 const char *drvname,
                                 const char *domname);
 void virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevice *dev,
-- 
2.42.2
Re: [PATCH v2 3/4] util: Change return type of virSCSIVHostDeviceSetUsedBy to void
Posted by Jiri Denemark 1 week, 5 days ago
On Thu, Nov 28, 2024 at 16:28:09 +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 | 3 +--
>  src/util/virscsivhost.c     | 6 ++----
>  src/util/virscsivhost.h     | 2 +-
>  3 files changed, 4 insertions(+), 7 deletions(-)
...
> diff --git a/src/util/virscsivhost.h b/src/util/virscsivhost.h
> index a7299382db..caaac26328 100644
> --- a/src/util/virscsivhost.h
> +++ b/src/util/virscsivhost.h
> @@ -50,7 +50,7 @@ void virSCSIVHostDeviceListDel(virSCSIVHostDeviceList *list,
>                                 virSCSIVHostDevice *dev);
>  virSCSIVHostDeviceList *virSCSIVHostDeviceListNew(void);
>  virSCSIVHostDevice *virSCSIVHostDeviceNew(const char *name);
> -int virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
> +void virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
>                                  const char *drvname,
>                                  const char *domname);

Indentation error.

Jirka
Re: [PATCH v2 3/4] util: Change return type of virSCSIVHostDeviceSetUsedBy to void
Posted by Jiri Denemark 1 week, 5 days ago
On Thu, Nov 28, 2024 at 16:28:09 +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 | 3 +--
>  src/util/virscsivhost.c     | 6 ++----
>  src/util/virscsivhost.h     | 2 +-
>  3 files changed, 4 insertions(+), 7 deletions(-)
> 
...
> diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
> index 15024d7106..05b89e58d6 100644
> --- a/src/util/virscsivhost.c
> +++ b/src/util/virscsivhost.c
...
> @@ -214,7 +212,7 @@ virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevice *dev,
>  {
>      *drv_name = dev->used_by_drvname;
>      *dom_name = dev->used_by_domname;
> - }
> +}

This is completely unrelated to what this patch is doing.

Jirka
Re: [PATCH v2 3/4] util: Change return type of virSCSIVHostDeviceSetUsedBy to void
Posted by Alexander Kuznetsov 1 week, 5 days ago
13.12.2024 16:32, Jiri Denemark wrote:
>> @@ -214,7 +212,7 @@ virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevice *dev,
>>   {
>>       *drv_name = dev->used_by_drvname;
>>       *dom_name = dev->used_by_domname;
>> - }
>> +}
> This is completely unrelated to what this patch is doing.
Yes, I just wanted to fix this small cosmetic thing, but I thought it was too
small for a separate patch. Should it be taken out separately,
or left until possible changes in the affected function?

-- 
Best regards,
Alexander Kuznetsov
Re: [PATCH v2 3/4] util: Change return type of virSCSIVHostDeviceSetUsedBy to void
Posted by Jiri Denemark 1 week, 5 days ago
On Fri, Dec 13, 2024 at 16:41:25 +0300, Alexander Kuznetsov wrote:
> 13.12.2024 16:32, Jiri Denemark wrote:
> >> @@ -214,7 +212,7 @@ virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevice *dev,
> >>   {
> >>       *drv_name = dev->used_by_drvname;
> >>       *dom_name = dev->used_by_domname;
> >> - }
> >> +}
> > This is completely unrelated to what this patch is doing.
> Yes, I just wanted to fix this small cosmetic thing, but I thought it was too
> small for a separate patch. Should it be taken out separately,
> or left until possible changes in the affected function?

I think I would just leave it for future changes in this function.

Jirka
[PATCH v2 4/4] logging: Change return type of virLogDaemonConfigFilePat to void
Posted by Alexander Kuznetsov 3 weeks, 6 days ago
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/logging/log_daemon.c        | 8 ++------
 src/logging/log_daemon_config.c | 4 +---
 src/logging/log_daemon_config.h | 2 +-
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index daf7ef4b2f..5a9be4a44e 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -692,14 +692,10 @@ int main(int argc, char **argv) {
         exit(EXIT_FAILURE);
     }
 
-    /* No explicit config, so try and find a default one */
+    /* No explicit config, so find a default one */
     if (remote_config_file == NULL) {
         implicit_conf = true;
-        if (virLogDaemonConfigFilePath(privileged,
-                                       &remote_config_file) < 0) {
-            VIR_ERROR(_("Can't determine config path"));
-            exit(EXIT_FAILURE);
-        }
+        virLogDaemonConfigFilePath(privileged, &remote_config_file);
     }
 
     /* Read the config file if it exists */
diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_config.c
index 248bd927d3..60c424ad84 100644
--- a/src/logging/log_daemon_config.c
+++ b/src/logging/log_daemon_config.c
@@ -33,7 +33,7 @@
 VIR_LOG_INIT("logging.log_daemon_config");
 
 
-int
+void
 virLogDaemonConfigFilePath(bool privileged, char **configfile)
 {
     if (privileged) {
@@ -45,8 +45,6 @@ virLogDaemonConfigFilePath(bool privileged, char **configfile)
 
         *configfile = g_strdup_printf("%s/virtlogd.conf", configdir);
     }
-
-    return 0;
 }
 
 
diff --git a/src/logging/log_daemon_config.h b/src/logging/log_daemon_config.h
index 43922feedf..5c10cc50d7 100644
--- a/src/logging/log_daemon_config.h
+++ b/src/logging/log_daemon_config.h
@@ -39,7 +39,7 @@ struct _virLogDaemonConfig {
 };
 
 
-int virLogDaemonConfigFilePath(bool privileged, char **configfile);
+void virLogDaemonConfigFilePath(bool privileged, char **configfile);
 virLogDaemonConfig *virLogDaemonConfigNew(bool privileged);
 void virLogDaemonConfigFree(virLogDaemonConfig *data);
 int virLogDaemonConfigLoadFile(virLogDaemonConfig *data,
-- 
2.42.2
Re: [PATCH v2 4/4] logging: Change return type of virLogDaemonConfigFilePat to void
Posted by Jiri Denemark 1 week, 5 days ago
On Thu, Nov 28, 2024 at 16:28:10 +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/logging/log_daemon.c        | 8 ++------
>  src/logging/log_daemon_config.c | 4 +---
>  src/logging/log_daemon_config.h | 2 +-
>  3 files changed, 4 insertions(+), 10 deletions(-)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>