mtd: delete unnecessary checks before two function calls

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Dec 15 19:59:08 PST 2014


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=05a221bb1f49e6eebc9a3858cb45506f403b3ab6
Commit:     05a221bb1f49e6eebc9a3858cb45506f403b3ab6
Parent:     775a9134f4398ca98a10af8cc3cf9b664017267f
Author:     Markus Elfring <elfring at users.sourceforge.net>
AuthorDate: Thu Nov 20 13:50:43 2014 +0100
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Tue Nov 25 22:44:10 2014 -0800

    mtd: delete unnecessary checks before two function calls
    
    The functions kfree() and pci_dev_put() test whether their argument is NULL
    and then return immediately. Thus the test around the call is not needed.
    
    This issue was detected by using the Coccinelle software.
    
    Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/chips/cfi_cmdset_0001.c | 3 +--
 drivers/mtd/devices/pmc551.c        | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 3096f3d..286b97a 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -2654,8 +2654,7 @@ static void cfi_intelext_destroy(struct mtd_info *mtd)
 	kfree(cfi);
 	for (i = 0; i < mtd->numeraseregions; i++) {
 		region = &mtd->eraseregions[i];
-		if (region->lockmap)
-			kfree(region->lockmap);
+		kfree(region->lockmap);
 	}
 	kfree(mtd->eraseregions);
 }
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index f02603e..708b7e8 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -812,8 +812,7 @@ static int __init init_pmc551(void)
 	}
 
 	/* Exited early, reference left over */
-	if (PCI_Device)
-		pci_dev_put(PCI_Device);
+	pci_dev_put(PCI_Device);
 
 	if (!pmc551list) {
 		printk(KERN_NOTICE "pmc551: not detected\n");



More information about the linux-mtd-cvs mailing list