summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-08-31 14:09:28 +0200
committerDaniel Stenberg <daniel@haxx.se>2021-09-01 08:35:31 +0200
commitc905459e878690942e9a0a8cd7f9ad57b6898efb (patch)
treeb50f5be9712a499e1393f63c68197a9101088049
parente8c8775eaa79fb93208c70a3c607e7e23222e4db (diff)
downloadcurl-c905459e878690942e9a0a8cd7f9ad57b6898efb.tar.gz
progress: make trspeed avoid floats
and compiler warnings for data conversions. Reported-by: MichaƂ Antoniak Fixes #7645 Closes #7653
-rw-r--r--lib/progress.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/progress.c b/lib/progress.c
index 62e61d45b..f5ef6bd52 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 */