[PATCH 2/6] net/vhost-user: Remove unused "err" from net_vhost_user_event() (CID 1612372)

Laurent Vivier posted 6 patches 4 months ago
Maintainers: Jason Wang <jasowang@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
[PATCH 2/6] net/vhost-user: Remove unused "err" from net_vhost_user_event() (CID 1612372)
Posted by Laurent Vivier 4 months ago
The "err" variable was declared but never used within the
net_vhost_user_event() function. This resulted in a dead code
warning (CID 1612372) from Coverity.

Remove the unused variable and the associated error block
to resolve the issue.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 net/vhost-user.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/vhost-user.c b/net/vhost-user.c
index 1c3b8b36f351..cec83e925ff0 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -329,7 +329,6 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
     NetClientState *ncs[MAX_QUEUE_NUM];
     NetVhostUserState *s;
     Chardev *chr;
-    Error *err = NULL;
     int queues;
 
     queues = qemu_find_net_clients_except(name, ncs,
@@ -375,10 +374,6 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
         /* Ignore */
         break;
     }
-
-    if (err) {
-        error_report_err(err);
-    }
 }
 
 static int net_vhost_user_init(NetClientState *peer, const char *device,
-- 
2.49.0
Re: [PATCH 2/6] net/vhost-user: Remove unused "err" from net_vhost_user_event() (CID 1612372)
Posted by Peter Maydell 3 months, 4 weeks ago
On Thu, 17 Jul 2025 at 18:52, Laurent Vivier <lvivier@redhat.com> wrote:
>
> The "err" variable was declared but never used within the
> net_vhost_user_event() function. This resulted in a dead code
> warning (CID 1612372) from Coverity.
>
> Remove the unused variable and the associated error block
> to resolve the issue.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  net/vhost-user.c | 5 -----
>  1 file changed, 5 deletions(-)
>
> diff --git a/net/vhost-user.c b/net/vhost-user.c
> index 1c3b8b36f351..cec83e925ff0 100644
> --- a/net/vhost-user.c
> +++ b/net/vhost-user.c
> @@ -329,7 +329,6 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
>      NetClientState *ncs[MAX_QUEUE_NUM];
>      NetVhostUserState *s;
>      Chardev *chr;
> -    Error *err = NULL;
>      int queues;
>
>      queues = qemu_find_net_clients_except(name, ncs,
> @@ -375,10 +374,6 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
>          /* Ignore */
>          break;
>      }
> -
> -    if (err) {
> -        error_report_err(err);
> -    }
>


Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM