All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] advansys: Remove redundant assignment to err and n_q_required
@ 2021-04-30  9:25 Jiapeng Chong
  2021-04-30 11:35 ` Matthew Wilcox
  2021-05-01  0:27 ` Finn Thain
  0 siblings, 2 replies; 3+ messages in thread
From: Jiapeng Chong @ 2021-04-30  9:25 UTC (permalink / raw)
  To: willy
  Cc: hare, jejb, martin.petersen, linux-scsi, linux-kernel, Jiapeng Chong

Variable err and n_q_required is set to '-ENOMEM' and '1', but they are
either overwritten or unused later on, so these are redundant assignments
that can be removed.

Clean up the following clang-analyzer warning:

drivers/scsi/advansys.c:11235:2: warning: Value stored to 'err' is never
read [clang-analyzer-deadcode.DeadStores].

drivers/scsi/advansys.c:8091:2: warning: Value stored to 'n_q_required'
is never read [clang-analyzer-deadcode.DeadStores].

drivers/scsi/advansys.c:11484:2: warning: Value stored to 'err' is never
read [clang-analyzer-deadcode.DeadStores].

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/scsi/advansys.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 800052f..f9969d4 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -8088,7 +8088,6 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 	sta = 0;
 	target_ix = scsiq->q2.target_ix;
 	tid_no = ASC_TIX_TO_TID(target_ix);
-	n_q_required = 1;
 	if (scsiq->cdbptr[0] == REQUEST_SENSE) {
 		if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
 			asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
@@ -11232,7 +11231,6 @@ static int advansys_vlb_probe(struct device *dev, unsigned int id)
 	if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
 		goto release_region;
 
-	err = -ENOMEM;
 	shost = scsi_host_alloc(&advansys_template, sizeof(*board));
 	if (!shost)
 		goto release_region;
@@ -11457,7 +11455,6 @@ static int advansys_pci_probe(struct pci_dev *pdev,
 
 	ioport = pci_resource_start(pdev, 0);
 
-	err = -ENOMEM;
 	shost = scsi_host_alloc(&advansys_template, sizeof(*board));
 	if (!shost)
 		goto release_region;
-- 
1.8.3.1


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

* Re: [PATCH] advansys: Remove redundant assignment to err and n_q_required
  2021-04-30  9:25 [PATCH] advansys: Remove redundant assignment to err and n_q_required Jiapeng Chong
@ 2021-04-30 11:35 ` Matthew Wilcox
  2021-05-01  0:27 ` Finn Thain
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2021-04-30 11:35 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: hare, jejb, martin.petersen, linux-scsi, linux-kernel

On Fri, Apr 30, 2021 at 05:25:28PM +0800, Jiapeng Chong wrote:
> Variable err and n_q_required is set to '-ENOMEM' and '1', but they are
> either overwritten or unused later on, so these are redundant assignments
> that can be removed.
> 
> Clean up the following clang-analyzer warning:
> 
> drivers/scsi/advansys.c:11235:2: warning: Value stored to 'err' is never
> read [clang-analyzer-deadcode.DeadStores].
> 
> drivers/scsi/advansys.c:8091:2: warning: Value stored to 'n_q_required'
> is never read [clang-analyzer-deadcode.DeadStores].
> 
> drivers/scsi/advansys.c:11484:2: warning: Value stored to 'err' is never
> read [clang-analyzer-deadcode.DeadStores].

I don't want to spend any time figuring out if this is a legitimate patch
or not.  Please stop running these analysers on this driver, and thank
the University of Minnesota for making me suspicious.

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

* Re: [PATCH] advansys: Remove redundant assignment to err and n_q_required
  2021-04-30  9:25 [PATCH] advansys: Remove redundant assignment to err and n_q_required Jiapeng Chong
  2021-04-30 11:35 ` Matthew Wilcox
@ 2021-05-01  0:27 ` Finn Thain
  1 sibling, 0 replies; 3+ messages in thread
From: Finn Thain @ 2021-05-01  0:27 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: willy, hare, jejb, martin.petersen, linux-scsi, linux-kernel

On Fri, 30 Apr 2021, Jiapeng Chong wrote:

> Variable err and n_q_required is set to '-ENOMEM' and '1', but they are
> either overwritten or unused later on, so these are redundant assignments
> that can be removed.
> 
> Clean up the following clang-analyzer warning:
> 
> drivers/scsi/advansys.c:11235:2: warning: Value stored to 'err' is never
> read [clang-analyzer-deadcode.DeadStores].
> 
> drivers/scsi/advansys.c:8091:2: warning: Value stored to 'n_q_required'
> is never read [clang-analyzer-deadcode.DeadStores].
> 
> drivers/scsi/advansys.c:11484:2: warning: Value stored to 'err' is never
> read [clang-analyzer-deadcode.DeadStores].
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  drivers/scsi/advansys.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
> index 800052f..f9969d4 100644
> --- a/drivers/scsi/advansys.c
> +++ b/drivers/scsi/advansys.c
> @@ -8088,7 +8088,6 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
>  	sta = 0;
>  	target_ix = scsiq->q2.target_ix;
>  	tid_no = ASC_TIX_TO_TID(target_ix);
> -	n_q_required = 1;
>  	if (scsiq->cdbptr[0] == REQUEST_SENSE) {
>  		if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
>  			asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
> @@ -11232,7 +11231,6 @@ static int advansys_vlb_probe(struct device *dev, unsigned int id)
>  	if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
>  		goto release_region;
>  
> -	err = -ENOMEM;
>  	shost = scsi_host_alloc(&advansys_template, sizeof(*board));
>  	if (!shost)
>  		goto release_region;

No, the correct way to resolve that particular clang warning is,

  free_host:
         scsi_host_put(shost);
  release_region:
         release_region(iop_base, ASC_IOADR_GAP);
-        return -ENODEV;
+        return err;
 }

> @@ -11457,7 +11455,6 @@ static int advansys_pci_probe(struct pci_dev *pdev,
>  
>  	ioport = pci_resource_start(pdev, 0);
>  
> -	err = -ENOMEM;
>  	shost = scsi_host_alloc(&advansys_template, sizeof(*board));
>  	if (!shost)
>  		goto release_region;
> 

No, that would be a behavioural change for the error path.

Moreover, the clang warning you claimed for line 11484 appears to be bogus 
with regard to mainline code. You may want to check your checker.

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

end of thread, other threads:[~2021-05-01  0:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30  9:25 [PATCH] advansys: Remove redundant assignment to err and n_q_required Jiapeng Chong
2021-04-30 11:35 ` Matthew Wilcox
2021-05-01  0:27 ` Finn Thain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.