[PATCH 13/17] conf: change virDomainDefMaybeAddHostdevSCSIcontroller() to return void

Laine Stump posted 17 patches 10 months, 1 week ago
[PATCH 13/17] conf: change virDomainDefMaybeAddHostdevSCSIcontroller() to return void
Posted by Laine Stump 10 months, 1 week ago
It can't fail.

Signed-off-by: Laine Stump <laine@redhat.com>
---
 src/conf/domain_conf.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 611b6a44c8..d3e95a2f92 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17200,7 +17200,7 @@ virDomainFeaturesDefParse(virDomainDef *def,
 }
 
 
-static int
+static void
 virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDef *def)
 {
     /* Look for any hostdev scsi dev */
@@ -17227,12 +17227,10 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDef *def)
     }
 
     if (maxController == -1)
-        return 0;
+        return;
 
     for (i = 0; i <= maxController; i++)
         virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_SCSI, i, newModel);
-
-    return 0;
 }
 
 
@@ -19497,8 +19495,7 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
          * post processing) because that will result in the failure to
          * load the controller during hostdev hotplug.
          */
-        if (virDomainDefMaybeAddHostdevSCSIcontroller(def) < 0)
-            return NULL;
+        virDomainDefMaybeAddHostdevSCSIcontroller(def);
     }
     VIR_FREE(nodes);
 
@@ -22379,8 +22376,7 @@ virDomainDefAddImplicitControllers(virDomainDef *def)
     if (virDomainDefMaybeAddSmartcardController(def) < 0)
         return -1;
 
-    if (virDomainDefMaybeAddHostdevSCSIcontroller(def) < 0)
-        return -1;
+    virDomainDefMaybeAddHostdevSCSIcontroller(def);
 
     return 0;
 }
-- 
2.47.1
Re: [PATCH 13/17] conf: change virDomainDefMaybeAddHostdevSCSIcontroller() to return void
Posted by Martin Kletzander 9 months, 3 weeks ago
On Tue, Feb 11, 2025 at 11:29:06PM -0500, Laine Stump wrote:
>It can't fail.
>
>Signed-off-by: Laine Stump <laine@redhat.com>
>---
> src/conf/domain_conf.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index 611b6a44c8..d3e95a2f92 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -17200,7 +17200,7 @@ virDomainFeaturesDefParse(virDomainDef *def,
> }
>
>
>-static int
>+static void
> virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDef *def)
> {
>     /* Look for any hostdev scsi dev */
>@@ -17227,12 +17227,10 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDef *def)
>     }
>
>     if (maxController == -1)
>-        return 0;
>+        return;
>


If `i` was ssize_t instead of size_t, you could've even removed the
above condition, so maybe I'm glad that it's size_t because that for
loop below would then gross me out =D

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>