From 3de3d7ee83bdfd3867d44aaa5e3f94b6e69c9225 Mon Sep 17 00:00:00 2001 From: dtucker Date: Thu, 30 Jun 2016 05:17:05 +0000 Subject: [PATCH] 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@ --- usr.bin/ssh/progressmeter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.bin/ssh/progressmeter.c b/usr.bin/ssh/progressmeter.c index d9af403dc69..3220e2cf4e4 100644 --- a/usr.bin/ssh/progressmeter.c +++ b/usr.bin/ssh/progressmeter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: progressmeter.c,v 1.44 2016/05/30 18:34:41 schwarze Exp $ */ +/* $OpenBSD: progressmeter.c,v 1.45 2016/06/30 05:17:05 dtucker Exp $ */ /* * Copyright (c) 2003 Nils Nordman. All rights reserved. * @@ -169,10 +169,10 @@ refresh_progress_meter(void) } /* percent of transfer done */ - if (end_pos != 0) - percent = ((float)cur_pos / end_pos) * 100; - else + if (end_pos == 0 || cur_pos == end_pos) percent = 100; + else + percent = ((float)cur_pos / end_pos) * 100; snprintf(buf + strlen(buf), win_size - strlen(buf), " %3d%% ", percent); -- 2.20.1