mtd/m25p80: retlen is never NULL

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Aug 13 16:59:02 EDT 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=b06cd21e2f0f75686f95afa5b71219b1408f5458
Commit:     b06cd21e2f0f75686f95afa5b71219b1408f5458
Parent:     d2b5bbef2198f82280441ab1ea7f634d615d913b
Author:     Dan Carpenter <error27 at gmail.com>
AuthorDate: Thu Aug 12 09:53:52 2010 +0200
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Thu Aug 12 12:26:22 2010 +0100

    mtd/m25p80: retlen is never NULL
    
    This is just a cleanup, it doesn't fix any bugs.
    
    These functions all check retlen inconsistently and it generates a
    warning in Smatch (http://smatch.sf.net).  If retlen were ever NULL it
    would cause an oops and the code has been this way since 2006 so someone
    would have complained.  Also I looked at other places that implemented
    the mtd read and write functions and they dereference retlen without
    checking.
    
    I removed the checks.
    
    Signed-off-by: Dan Carpenter <error27 at gmail.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/devices/m25p80.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index f90941a..83c9086 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -347,8 +347,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,
 	spi_message_add_tail(&t[1], &m);
 
 	/* Byte count starts at zero. */
-	if (retlen)
-		*retlen = 0;
+	*retlen = 0;
 
 	mutex_lock(&flash->lock);
 
@@ -394,8 +393,7 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,
 			dev_name(&flash->spi->dev), __func__, "to",
 			(u32)to, len);
 
-	if (retlen)
-		*retlen = 0;
+	*retlen = 0;
 
 	/* sanity checks */
 	if (!len)
@@ -466,8 +464,7 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,
 
 			spi_sync(flash->spi, &m);
 
-			if (retlen)
-				*retlen += m.actual_length - m25p_cmdsz(flash);
+			*retlen += m.actual_length - m25p_cmdsz(flash);
 		}
 	}
 
@@ -485,8 +482,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
 	size_t actual;
 	int cmd_sz, ret;
 
-	if (retlen)
-		*retlen = 0;
+	*retlen = 0;
 
 	/* sanity checks */
 	if (!len)



More information about the linux-mtd-cvs mailing list