cmd: mem: Correctly count the errors in mtest
authorStefan Roese <sr@denx.de>
Thu, 5 Mar 2020 06:21:29 +0000 (07:21 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 17 Apr 2020 16:32:36 +0000 (12:32 -0400)
This patch changes mtest to correctly count the overall errors and
print them even in the abort (Ctrl-C) case.

Signed-off-by: Stefan Roese <sr@denx.de>
cmd/mem.c

index 6d54f1952727e2cefcfacf06e8b52b3b8091c7c6..9367278aa8a5bb502afe7874780ad7bcbdd6af7b 100644 (file)
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -871,7 +871,7 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
        ulong start, end;
        vu_long *buf, *dummy;
        ulong iteration_limit = 0;
-       int ret;
+       ulong count = 0;
        ulong errs = 0; /* number of errors, or -1 if interrupted */
        ulong pattern = 0;
        int iteration;
@@ -929,6 +929,7 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
                }
                if (errs == -1UL)
                        break;
+               count += errs;
        }
 
        /*
@@ -947,14 +948,10 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
        if (errs == -1UL) {
                /* Memory test was aborted - write a newline to finish off */
                putc('\n');
-               ret = 1;
-       } else {
-               printf("Tested %d iteration(s) with %lu errors.\n",
-                       iteration, errs);
-               ret = errs != 0;
        }
+       printf("Tested %d iteration(s) with %lu errors.\n", iteration, count);
 
-       return ret;
+       return errs != 0;
 }
 #endif /* CONFIG_CMD_MEMTEST */