kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: target: vhost-scsi: remove redundant initialization of variable ret
@ 2021-03-03 13:43 Colin King
  2021-03-04 17:15 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-03-03 13:43 UTC (permalink / raw)
  To: Michael S . Tsirkin, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
	virtualization, kvm, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The variable ret is being initialized with a value that is never read
and it is being updated later with a new value.  The initialization is
redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/vhost/scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index d16c04dcc144..9129ab8187fd 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -2465,7 +2465,7 @@ static const struct target_core_fabric_ops vhost_scsi_ops = {
 
 static int __init vhost_scsi_init(void)
 {
-	int ret = -ENOMEM;
+	int ret;
 
 	pr_debug("TCM_VHOST fabric module %s on %s/%s"
 		" on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname,
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: target: vhost-scsi: remove redundant initialization of variable ret
  2021-03-03 13:43 [PATCH] scsi: target: vhost-scsi: remove redundant initialization of variable ret Colin King
@ 2021-03-04 17:15 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2021-03-04 17:15 UTC (permalink / raw)
  To: Colin King
  Cc: Michael S . Tsirkin, Jason Wang, Paolo Bonzini, virtualization,
	kvm, netdev, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2329 bytes --]

On Wed, Mar 03, 2021 at 01:43:39PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The variable ret is being initialized with a value that is never read
> and it is being updated later with a new value.  The initialization is
> redundant and can be removed.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/vhost/scsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Which kernel version is this patch based on?

If it's a fix for a patch that hasn't landed yet, please indicate this.
A "Fixes: ..." tag should be added to this patch as well.

I looked at linux.git/master commit f69d02e37a85645aa90d18cacfff36dba370f797 and see this:

  static int __init vhost_scsi_init(void)
  {
          int ret = -ENOMEM;

          pr_debug("TCM_VHOST fabric module %s on %s/%s"
                  " on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname,
                  utsname()->machine);

          /*
           * Use our own dedicated workqueue for submitting I/O into
           * target core to avoid contention within system_wq.
           */
          vhost_scsi_workqueue = alloc_workqueue("vhost_scsi", 0, 0);
          if (!vhost_scsi_workqueue)
                  goto out;

We need ret's initialization value here ^

          ret = vhost_scsi_register();
          if (ret < 0)
                  goto out_destroy_workqueue;

          ret = target_register_template(&vhost_scsi_ops);
          if (ret < 0)
                  goto out_vhost_scsi_deregister;

          return 0;

  out_vhost_scsi_deregister:
          vhost_scsi_deregister();
  out_destroy_workqueue:
          destroy_workqueue(vhost_scsi_workqueue);
  out:
          return ret;
  };


> 
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index d16c04dcc144..9129ab8187fd 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -2465,7 +2465,7 @@ static const struct target_core_fabric_ops vhost_scsi_ops = {
>  
>  static int __init vhost_scsi_init(void)
>  {
> -	int ret = -ENOMEM;
> +	int ret;
>  
>  	pr_debug("TCM_VHOST fabric module %s on %s/%s"
>  		" on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname,
> -- 
> 2.30.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-04 17:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 13:43 [PATCH] scsi: target: vhost-scsi: remove redundant initialization of variable ret Colin King
2021-03-04 17:15 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).