Whamcloud - gitweb
e2image: calculate progress rate using floating point
authorTheodore Ts'o <tytso@mit.edu>
Sun, 24 Jun 2018 04:32:51 +0000 (00:32 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 24 Jun 2018 04:32:51 +0000 (00:32 -0400)
One of the divisions used when caluclate the progress rate was being
done as an integer instead of floating-point operation.  This could
cause the end result to not be as accurate as we would like.

Fixes-Coverity-Bug: 1297513
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/e2image.c

index 83ae633..99a2ed9 100644 (file)
@@ -552,7 +552,7 @@ static void sigint_handler(int unused EXT2FS_ATTR((unused)))
 
 #define calc_percent(a, b) ((int) ((100.0 * (((float) (a)) / \
                                             ((float) (b)))) + 0.5))
-#define calc_rate(t, b, d) (((float)(t) / ((1024 * 1024) / (b))) / (d))
+#define calc_rate(t, b, d) (((float)(t) / ((float)(1024 * 1024) / (b))) / (d))
 
 static int print_progress(blk64_t num, blk64_t total)
 {