mtd-tests: nandbiterrs: Fix issue that just insert error at bit 7
diff mbox series

Message ID 20190429032834.7550-1-xiaolei.li@mediatek.com
State New
Delegated to: David Oberhollenzer
Headers show
Series
  • mtd-tests: nandbiterrs: Fix issue that just insert error at bit 7
Related show

Commit Message

xiaolei li April 29, 2019, 3:28 a.m. UTC
From: Xiaolei Li <xiaolei.li@mediatek.com>

The function insert_biterror should be designed to insert error at
the first '1' bit starting at offset byte.

But now, only bit 7 of each byte is checked, because checking mask
is always 0x80.

So, do right shift for checking mask after each checking to check
the whole 8 bits of each bytes.

Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
---
 tests/mtd-tests/nandbiterrs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Oberhollenzer April 29, 2019, 6:44 a.m. UTC | #1
Applied to mtd-utils.git master.

Thanks,

David

Patch
diff mbox series

diff --git a/tests/mtd-tests/nandbiterrs.c b/tests/mtd-tests/nandbiterrs.c
index 24a6c03..f583c14 100644
--- a/tests/mtd-tests/nandbiterrs.c
+++ b/tests/mtd-tests/nandbiterrs.c
@@ -333,7 +333,7 @@  static int insert_biterror(void)
 	int bit, mask, byte;
 
 	for (byte = 0; byte < pagesize; ++byte) {
-		for (bit = 7, mask = 0x80; bit >= 0; bit--, mask>>=0) {
+		for (bit = 7, mask = 0x80; bit >= 0; bit--, mask >>= 1) {
 			if (wbuffer[byte] & mask) {
 				wbuffer[byte] &= ~mask;
 				printf("Inserted biterror @ %u/%u\n", byte, bit);