On 24.09.21 23:06, Marek Behún wrote:
From: Pali Rohár <p...@kernel.org>

Ensure that `pos` is still in range up to the `width` so printing 100%
works also for bigger images. After printing 100% progress reset it to
zero, so that next progressbar can be started.

Signed-off-by: Pali Rohár <p...@kernel.org>
Reviewed-by: Marek Behún <marek.be...@nic.cz>

Reviewed-by: Stefan Roese <s...@denx.de>

Thanks,
Stefan

---
  tools/kwboot.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/kwboot.c b/tools/kwboot.c
index 3d9f73e697..eb4b3fe230 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -140,12 +140,14 @@ __progress(int pct, char c)
        fputc(c, stdout);
nl = "]\n";
-       pos++;
+       pos = (pos + 1) % width;
if (pct == 100) {
-               while (pos++ < width)
+               while (pos && pos++ < width)
                        fputc(' ', stdout);
                fputs(nl, stdout);
+               nl = "";
+               pos = 0;
        }
fflush(stdout);
@@ -162,6 +164,9 @@ kwboot_progress(int _pct, char c)
if (kwboot_verbose)
                __progress(pct, c);
+
+       if (pct == 100)
+               pct = 0;
  }
static int



Viele Grüße,
Stefan

--
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de

Reply via email to