[PATCH v2 5/6] hyperv: Change return type of hypervCheckParams to void

Alexander Kuznetsov posted 6 patches 3 weeks, 2 days ago
[PATCH v2 5/6] hyperv: Change return type of hypervCheckParams to void
Posted by Alexander Kuznetsov 3 weeks, 2 days ago
This function return value is invariant since VIR_EXPAND_N check
removal in 7d2fd6e, 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/hyperv/hyperv_wmi.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index 8bc376e22f..0b82f1f131 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -184,14 +184,12 @@ hypervFreeInvokeParams(hypervInvokeParamsList *params)
 }
 
 
-static inline int
+static inline void
 hypervCheckParams(hypervInvokeParamsList *params)
 {
     if (params->nbParams + 1 > params->nbAvailParams) {
         VIR_EXPAND_N(params->params, params->nbAvailParams, 5);
     }
-
-    return 0;
 }
 
 
@@ -212,8 +210,7 @@ hypervAddSimpleParam(hypervInvokeParamsList *params, const char *name,
 {
     hypervParam *p = NULL;
 
-    if (hypervCheckParams(params) < 0)
-        return -1;
+    hypervCheckParams(params);
 
     p = &params->params[params->nbParams];
     p->type = HYPERV_SIMPLE_PARAM;
@@ -245,8 +242,7 @@ hypervAddEprParam(hypervInvokeParamsList *params,
 {
     hypervParam *p = NULL;
 
-    if (hypervCheckParams(params) < 0)
-        return -1;
+    hypervCheckParams(params);
 
     p = &params->params[params->nbParams];
     p->type = HYPERV_EPR_PARAM;
@@ -333,8 +329,7 @@ hypervAddEmbeddedParam(hypervInvokeParamsList *params,
 {
     hypervParam *p = NULL;
 
-    if (hypervCheckParams(params) < 0)
-        return -1;
+    hypervCheckParams(params);
 
     p = &params->params[params->nbParams];
     p->type = HYPERV_EMBEDDED_PARAM;
-- 
2.42.2
Re: [PATCH v2 5/6] hyperv: Change return type of hypervCheckParams to void
Posted by Jiri Denemark 1 week, 1 day ago
On Thu, Nov 28, 2024 at 18:21:21 +0300, Alexander Kuznetsov wrote:
> This function return value is invariant since VIR_EXPAND_N check
> removal in 7d2fd6e, 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/hyperv/hyperv_wmi.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)

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