[PATCH] cmd: mem: fix range of bitflip test
Stefan Roese
sr at denx.de
Wed Sep 9 10:49:29 CEST 2020
Hi Ralph,
On 09.09.20 03:33, Ralph Siemsen wrote:
> The bitflip test uses two equal sized memory buffers. This is achived
> by splitting the range of memory into two pieces. The address of the
> second buffer was not correctly calulated, thus the bitflip test would
calculated
> accessing memory beyond the end of the specified range.
>
> A second problem arises because u-boot "mtest" command expects the
> ending address to be inclusive. When computing (end - start) this
> results in missing 1 byte of the requested length. The bitflip test in
> turn misses the last word.
>
> Fixes: 8e434cb705d463bc8cff935160e4fb4c77cb99ab ("cmd: mem: Add bitflip
> memory test to alternate mtest")
>
> Signed-off-by: Ralph Siemsen <ralph.siemsen at linaro.org>
> --
> TODO/FIXME: maybe the ending address should be automatically aligned?
>
> Change-Id: Ie641d04e731fc5bc6a3bbef914bf7fad136cdc94
> ---
> cmd/mem.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/cmd/mem.c b/cmd/mem.c
> index 9b97f7bf69..88e15b2d61 100644
> --- a/cmd/mem.c
> +++ b/cmd/mem.c
> @@ -988,8 +988,9 @@ static int do_mem_mtest(struct cmd_tbl *cmdtp, int flag, int argc,
> break;
> count += errs;
> errs = test_bitflip_comparison(buf,
> - buf + (end - start) / 2,
> - (end - start) /
> + buf + (end - start + 1) / 2 /
> + sizeof(unsigned long),
> + (end - start + 1) / 2 /
> sizeof(unsigned long));
Thanks for finding and fixing this:
Reviewed-by: Stefan Roese <sr at denx.de>
Perhaps you could assign a variable to make the lines a bit shorter:
half_size = (end - start + 1) / 2 /
sizeof(unsigned long);
errs = test_bitflip_comparison(buf,
buf + half_size,
half_size);
?
Thanks,
Stefan
More information about the U-Boot
mailing list