[PATCH v2 1/6] access: Change return type of virAccessDriverStackAppend to void

Alexander Kuznetsov posted 6 patches 3 weeks, 2 days ago
[PATCH v2 1/6] access: Change return type of virAccessDriverStackAppend 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/access/viraccessdriverstack.c | 4 +---
 src/access/viraccessdriverstack.h | 2 +-
 src/access/viraccessmanager.c     | 5 +----
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/access/viraccessdriverstack.c b/src/access/viraccessdriverstack.c
index fb9ea71665..9d6a0d4d1b 100644
--- a/src/access/viraccessdriverstack.c
+++ b/src/access/viraccessdriverstack.c
@@ -32,7 +32,7 @@ struct _virAccessDriverStackPrivate {
 };
 
 
-int virAccessDriverStackAppend(virAccessManager *manager,
+void virAccessDriverStackAppend(virAccessManager *manager,
                                virAccessManager *child)
 {
     virAccessDriverStackPrivate *priv = virAccessManagerGetPrivateData(manager);
@@ -40,8 +40,6 @@ int virAccessDriverStackAppend(virAccessManager *manager,
     VIR_EXPAND_N(priv->managers, priv->managersLen, 1);
 
     priv->managers[priv->managersLen-1] = child;
-
-    return 0;
 }
 
 
diff --git a/src/access/viraccessdriverstack.h b/src/access/viraccessdriverstack.h
index abcfc30ec3..f878ef1989 100644
--- a/src/access/viraccessdriverstack.h
+++ b/src/access/viraccessdriverstack.h
@@ -23,7 +23,7 @@
 #include "access/viraccessdriver.h"
 
 
-int virAccessDriverStackAppend(virAccessManager *manager,
+void virAccessDriverStackAppend(virAccessManager *manager,
                                virAccessManager *child);
 
 extern virAccessDriver accessDriverStack;
diff --git a/src/access/viraccessmanager.c b/src/access/viraccessmanager.c
index 481528c3b9..6d9fdee5f1 100644
--- a/src/access/viraccessmanager.c
+++ b/src/access/viraccessmanager.c
@@ -164,10 +164,7 @@ virAccessManager *virAccessManagerNewStack(const char **names)
         if (!child)
             goto error;
 
-        if (virAccessDriverStackAppend(manager, child) < 0) {
-            virObjectUnref(child);
-            goto error;
-        }
+        virAccessDriverStackAppend(manager, child);
     }
 
     return manager;
-- 
2.42.2
Re: [PATCH v2 1/6] access: Change return type of virAccessDriverStackAppend to void
Posted by Jiri Denemark 1 week, 1 day ago
On Thu, Nov 28, 2024 at 18:21:17 +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/access/viraccessdriverstack.c | 4 +---
>  src/access/viraccessdriverstack.h | 2 +-
>  src/access/viraccessmanager.c     | 5 +----
>  3 files changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/src/access/viraccessdriverstack.c b/src/access/viraccessdriverstack.c
> index fb9ea71665..9d6a0d4d1b 100644
> --- a/src/access/viraccessdriverstack.c
> +++ b/src/access/viraccessdriverstack.c
> @@ -32,7 +32,7 @@ struct _virAccessDriverStackPrivate {
>  };
>  
>  
> -int virAccessDriverStackAppend(virAccessManager *manager,
> +void virAccessDriverStackAppend(virAccessManager *manager,
>                                 virAccessManager *child)

Indentation error

>  {
>      virAccessDriverStackPrivate *priv = virAccessManagerGetPrivateData(manager);
> @@ -40,8 +40,6 @@ int virAccessDriverStackAppend(virAccessManager *manager,
>      VIR_EXPAND_N(priv->managers, priv->managersLen, 1);
>  
>      priv->managers[priv->managersLen-1] = child;
> -
> -    return 0;
>  }
>  
>  
> diff --git a/src/access/viraccessdriverstack.h b/src/access/viraccessdriverstack.h
> index abcfc30ec3..f878ef1989 100644
> --- a/src/access/viraccessdriverstack.h
> +++ b/src/access/viraccessdriverstack.h
> @@ -23,7 +23,7 @@
>  #include "access/viraccessdriver.h"
>  
>  
> -int virAccessDriverStackAppend(virAccessManager *manager,
> +void virAccessDriverStackAppend(virAccessManager *manager,
>                                 virAccessManager *child);

Indentation error

>  
>  extern virAccessDriver accessDriverStack;

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