lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1327674295-3700-7-git-send-email-akinobu.mita@gmail.com>
Date:	Fri, 27 Jan 2012 23:24:54 +0900
From:	Akinobu Mita <akinobu.mita@...il.com>
To:	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org
Cc:	Akinobu Mita <akinobu.mita@...il.com>,
	David Woodhouse <dwmw2@...radead.org>,
	linux-mtd@...ts.infradead.org
Subject: [PATCH] mtd/tests: use memchr_inv

Use memchr_inv to check if the data contains all 0xFF bytes.  It is
faster than looping for each byte.

Signed-off-by: Akinobu Mita <akinobu.mita@...il.com>
Cc: David Woodhouse <dwmw2@...radead.org>
Cc: linux-mtd@...ts.infradead.org
---
 drivers/mtd/tests/mtd_pagetest.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c
index 252ddb0..08847cf 100644
--- a/drivers/mtd/tests/mtd_pagetest.c
+++ b/drivers/mtd/tests/mtd_pagetest.c
@@ -401,6 +401,7 @@ static int erasetest(void)
 	size_t read, written;
 	int err = 0, i, ebnum, ok = 1;
 	loff_t addr0;
+	unsigned char *p;
 
 	printk(PRINT_PREF "erasetest\n");
 
@@ -442,14 +443,13 @@ static int erasetest(void)
 
 	printk(PRINT_PREF "verifying 1st page of block %d is all 0xff\n",
 	       ebnum);
-	for (i = 0; i < pgsize; ++i)
-		if (twopages[i] != 0xff) {
-			printk(PRINT_PREF "verifying all 0xff failed at %d\n",
-			       i);
-			errcnt += 1;
-			ok = 0;
-			break;
-		}
+	p = memchr_inv(twopages, 0xff, pgsize);
+	if (p) {
+		printk(PRINT_PREF "verifying all 0xff failed at %d\n",
+			       p - twopages);
+		errcnt += 1;
+		ok = 0;
+	}
 
 	if (ok && !err)
 		printk(PRINT_PREF "erasetest ok\n");
-- 
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ