From: Daniel Stenberg Date: Tue, 31 Aug 2021 12:09:28 +0000 (+0200) Subject: progress: make trspeed avoid floats X-Git-Tag: curl-7_79_0~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c905459e878690942e9a0a8cd7f9ad57b6898efb;p=thirdparty%2Fcurl.git progress: make trspeed avoid floats and compiler warnings for data conversions. Reported-by: MichaƂ Antoniak Fixes #7645 Closes #7653 --- diff --git a/lib/progress.c b/lib/progress.c index 62e61d45b4..f5ef6bd526 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -377,7 +377,12 @@ static curl_off_t trspeed(curl_off_t size, /* number of bytes */ { if(us < 1) return size * 1000000; - return (curl_off_t)((long double)size/(long double)us * 1000000); + else if(size < CURL_OFF_T_MAX/1000000) + return (size * 1000000) / us; + else if(us >= 1000000) + return size / (us / 1000000); + else + return CURL_OFF_T_MAX; } /* returns TRUE if it's time to show the progress meter */