diff options
author | Pali Rohár <pali@kernel.org> | 2021-09-24 23:06:46 +0200 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2021-10-01 11:07:13 +0200 |
commit | 5a1f8cbe86ddc5802f661145926423d63f34e48a (patch) | |
tree | 5493690f7ab987903c44885e106f4db9b04cc9ed /tools | |
parent | d8cc851dd12e5782d491daf46eea7b0b34758fc5 (diff) | |
download | u-boot-5a1f8cbe86ddc5802f661145926423d63f34e48a.zip u-boot-5a1f8cbe86ddc5802f661145926423d63f34e48a.tar.gz u-boot-5a1f8cbe86ddc5802f661145926423d63f34e48a.tar.bz2 |
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 <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/kwboot.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c index 3d9f73e..eb4b3fe 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 |