public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mtest: Fix end address of increment/decrement test
@ 2010-05-20 17:08 Peter Tyser
  2010-05-20 18:43 ` Wolfgang Denk
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Tyser @ 2010-05-20 17:08 UTC (permalink / raw)
  To: u-boot

From: John Schmoller <jschmoller@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@xes-inc.com>
Signed-off-by: Peter Tyser <ptyser@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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-05-20 22:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-20 17:08 [U-Boot] [PATCH] mtest: Fix end address of increment/decrement test Peter Tyser
2010-05-20 18:43 ` Wolfgang Denk
2010-05-20 19:07   ` Peter Tyser
2010-05-20 19:44     ` Wolfgang Denk
2010-05-20 20:11       ` Peter Tyser
2010-05-20 20:32         ` Wolfgang Denk
2010-05-20 22:00           ` Peter Tyser
2010-05-20 22:07             ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox