[PATCH 2/6] show_progress: fix progress bar for files > 32 MiB
Marc Kleine-Budde
mkl at pengutronix.de
Tue Jan 24 05:51:03 EST 2012
The next limit with the current code will probably 2GiB.
Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
lib/show_progress.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/show_progress.c b/lib/show_progress.c
index 333f498..39808d2 100644
--- a/lib/show_progress.c
+++ b/lib/show_progress.c
@@ -22,6 +22,7 @@
#include <common.h>
#include <progress.h>
+#include <asm-generic/div64.h>
#define HASHES_PER_LINE 65
@@ -38,8 +39,11 @@ void show_progress(int now)
return;
}
- if (progress_max)
- now = now * HASHES_PER_LINE / progress_max;
+ if (progress_max) {
+ uint64_t tmp = (int64_t)now * HASHES_PER_LINE;
+ do_div(tmp, progress_max);
+ now = tmp;
+ }
while (printed < now) {
if (!(printed % HASHES_PER_LINE) && printed)
--
1.7.4.1
More information about the barebox
mailing list