diff options
author | dtucker@openbsd.org <dtucker@openbsd.org> | 2016-06-30 05:17:05 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2016-07-08 13:46:59 +1000 |
commit | e683fc6f1c8c7295648dbda679df8307786ec1ce (patch) | |
tree | 9511bdd3159204478945e3f63490862e3d3b00b5 | |
parent | 772e6cec0ed740fc7db618dc30b4134f5a358b43 (diff) |
upstream commit
Explicitly check for 100% completion to avoid potential
floating point rounding error, which could cause progressmeter to report 99%
on completion. While there invert the test so the 100% case is clearer. with
& ok djm@
Upstream-ID: a166870c5878e422f3c71ff802e2ccd7032f715d
-rw-r--r-- | progressmeter.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/progressmeter.c b/progressmeter.c index d3e0223e5..fe9bf52e4 100644 --- a/progressmeter.c +++ b/progressmeter.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: progressmeter.c,v 1.44 2016/05/30 18:34:41 schwarze Exp $ */ | 1 | /* $OpenBSD: progressmeter.c,v 1.45 2016/06/30 05:17:05 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2003 Nils Nordman. All rights reserved. | 3 | * Copyright (c) 2003 Nils Nordman. All rights reserved. |
4 | * | 4 | * |
@@ -171,10 +171,10 @@ refresh_progress_meter(void) | |||
171 | } | 171 | } |
172 | 172 | ||
173 | /* percent of transfer done */ | 173 | /* percent of transfer done */ |
174 | if (end_pos != 0) | 174 | if (end_pos == 0 || cur_pos == end_pos) |
175 | percent = ((float)cur_pos / end_pos) * 100; | ||
176 | else | ||
177 | percent = 100; | 175 | percent = 100; |
176 | else | ||
177 | percent = ((float)cur_pos / end_pos) * 100; | ||
178 | snprintf(buf + strlen(buf), win_size - strlen(buf), | 178 | snprintf(buf + strlen(buf), win_size - strlen(buf), |
179 | " %3d%% ", percent); | 179 | " %3d%% ", percent); |
180 | 180 | ||