[U-Boot] [PATCH] mtest: Fix end address of increment/decrement test

Peter Tyser ptyser at xes-inc.com
Thu May 20 19:08:03 CEST 2010


From: John Schmoller <jschmoller at xes-inc.com>

The incrememt/decrement test has an off-by-one error which results in an
extra 4 bytes being tested past the specified end address.  For
instance, when running "mtest 0x1000 0x2000", the bytes 0x2000-0x2003
would be tested which is counterintuitive and at odds with the end
address calculation of other U-Boot memory tests.

Example of original behavior:
=> md 0x2000 10
00002000: deadbeef deadbeef deadbeef deadbeef    ................
00002010: deadbeef deadbeef deadbeef deadbeef    ................
00002020: deadbeef deadbeef deadbeef deadbeef    ................
00002030: deadbeef deadbeef deadbeef deadbeef    ................
=> mtest 0x1000 0x2000 1 1
Testing 00001000 ... 00002000:
Tested 1 iteration(s) with 0 errors.
=> md 0x2000 10
00002000: 00000000 deadbeef deadbeef deadbeef    ................
00002010: deadbeef deadbeef deadbeef deadbeef    ................
00002020: deadbeef deadbeef deadbeef deadbeef    ................
00002030: deadbeef deadbeef deadbeef deadbeef    ................
=>

This change results in the memory at 0x2000 not being modified by mtest
in the example above.

Signed-off-by: John Schmoller <jschmoller at xes-inc.com>
Signed-off-by: Peter Tyser <ptyser at xes-inc.com>
---
 common/cmd_mem.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 1839330..0bc3c70 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -862,7 +862,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		 *
 		 * Returns:     0 if the test succeeds, 1 if the test fails.
 		 */
-		num_words = ((ulong)end - (ulong)start)/sizeof(vu_long) + 1;
+		num_words = ((ulong)end - (ulong)start)/sizeof(vu_long);
 
 		/*
 		 * Fill memory with a known pattern.
-- 
1.7.0.4



More information about the U-Boot mailing list