From: Pali Rohár Date: Fri, 24 Sep 2021 21:06:46 +0000 (+0200) Subject: tools: kwboot: Fix printing progress X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=5a1f8cbe86ddc5802f661145926423d63f34e48a;p=u-boot.git tools: kwboot: Fix printing progress 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 Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- 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