[UBI] drivers/mtd/ubi/scan.c: kmalloc + memset conversion to kzalloc

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed Aug 1 06:59:01 EDT 2007


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=d9b0744d6c75f7b268b728cdd1843f31bdeba311
Commit:     d9b0744d6c75f7b268b728cdd1843f31bdeba311
Parent:     4fb4caa639a27a3cb0b3bfbf2041524af43efff9
Author:     Mariusz Kozlowski <m.kozlowski at tuxland.pl>
AuthorDate: Wed Aug 1 00:02:10 2007 +0200
Committer:  David Woodhouse <dwmw2 at infradead.org>
CommitDate: Wed Aug 1 11:04:05 2007 +0100

    [UBI] drivers/mtd/ubi/scan.c: kmalloc + memset conversion to kzalloc
    
    To be able to convert kmalloc + memset(..., 1, ...) to kzalloc this patch
    reverses the logic around 'buf'.
    
    Signed-off-by: Mariusz Kozlowski <m.kozlowski at tuxland.pl>
    Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
 drivers/mtd/ubi/scan.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 94ee549..29c41ee 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -1314,11 +1314,10 @@ static int paranoid_check_si(const struct ubi_device *ubi,
 	 * Make sure that all the physical eraseblocks are in one of the lists
 	 * or trees.
 	 */
-	buf = kmalloc(ubi->peb_count, GFP_KERNEL);
+	buf = kzalloc(ubi->peb_count, GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
-	memset(buf, 1, ubi->peb_count);
 	for (pnum = 0; pnum < ubi->peb_count; pnum++) {
 		err = ubi_io_is_bad(ubi, pnum);
 		if (err < 0) {
@@ -1326,28 +1325,28 @@ static int paranoid_check_si(const struct ubi_device *ubi,
 			return err;
 		}
 		else if (err)
-			buf[pnum] = 0;
+			buf[pnum] = 1;
 	}
 
 	ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb)
 		ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb)
-			buf[seb->pnum] = 0;
+			buf[seb->pnum] = 1;
 
 	list_for_each_entry(seb, &si->free, u.list)
-		buf[seb->pnum] = 0;
+		buf[seb->pnum] = 1;
 
 	list_for_each_entry(seb, &si->corr, u.list)
-		buf[seb->pnum] = 0;
+		buf[seb->pnum] = 1;
 
 	list_for_each_entry(seb, &si->erase, u.list)
-		buf[seb->pnum] = 0;
+		buf[seb->pnum] = 1;
 
 	list_for_each_entry(seb, &si->alien, u.list)
-		buf[seb->pnum] = 0;
+		buf[seb->pnum] = 1;
 
 	err = 0;
 	for (pnum = 0; pnum < ubi->peb_count; pnum++)
-		if (buf[pnum]) {
+		if (!buf[pnum]) {
 			ubi_err("PEB %d is not referred", pnum);
 			err = 1;
 		}



More information about the linux-mtd-cvs mailing list