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>
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);
if (kwboot_verbose)
__progress(pct, c);
+
+ if (pct == 100)
+ pct = 0;
}
static int