diff mbox series

scsi: sym53c8xx_2: remove redundant assignment to retv

Message ID 20190809175932.10197-1-colin.king@canonical.com (mailing list archive)
State Mainlined
Commit 1d4f4a5e507f5879af56370380df600dd9119030
Headers show
Series scsi: sym53c8xx_2: remove redundant assignment to retv | expand

Commit Message

Colin King Aug. 9, 2019, 5:59 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Variable retv is initialized to a value that is never read and it
is re-assigned later. The initialization is redundant and can be
removed.

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

Comments

Matthew Wilcox (Oracle) Aug. 9, 2019, 6:17 p.m. UTC | #1
On Fri, Aug 09, 2019 at 06:59:32PM +0100, Colin King wrote:
> Variable retv is initialized to a value that is never read and it
> is re-assigned later. The initialization is redundant and can be
> removed.

Acked-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Seems like a bit of a pointless class of warnings, given that gcc now
initialises all locals.  But I'm happy for James or Martin to pick it up.
Martin K. Petersen Aug. 13, 2019, 1:58 a.m. UTC | #2
Colin,

> Variable retv is initialized to a value that is never read and it is
> re-assigned later. The initialization is redundant and can be removed.

Applied to 5.4/scsi-queue, thanks!
Dan Carpenter Aug. 13, 2019, 1:14 p.m. UTC | #3
On Fri, Aug 09, 2019 at 11:17:33AM -0700, Matthew Wilcox wrote:
> On Fri, Aug 09, 2019 at 06:59:32PM +0100, Colin King wrote:
> > Variable retv is initialized to a value that is never read and it
> > is re-assigned later. The initialization is redundant and can be
> > removed.
> 
> Acked-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> 
> Seems like a bit of a pointless class of warnings, given that gcc now
> initialises all locals.  But I'm happy for James or Martin to pick it up.

GCC doesn't initialize all locals.  Just some depending on the
optimization level.  It's related to a bug that's several years old.

This warning does find some bugs.  The common one is where people forget
to check the return.

	ret = something();
	// blank line here indicates that ret is never checked again.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/scsi/sym53c8xx_2/sym_nvram.c b/drivers/scsi/sym53c8xx_2/sym_nvram.c
index dd3f07b31612..9dc17f1288f9 100644
--- a/drivers/scsi/sym53c8xx_2/sym_nvram.c
+++ b/drivers/scsi/sym53c8xx_2/sym_nvram.c
@@ -648,7 +648,7 @@  static int sym_read_T93C46_nvram(struct sym_device *np, Tekram_nvram *nvram)
 {
 	u_char gpcntl, gpreg;
 	u_char old_gpcntl, old_gpreg;
-	int retv = 1;
+	int retv;
 
 	/* save current state of GPCNTL and GPREG */
 	old_gpreg	= INB(np, nc_gpreg);