]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
progress: make trspeed avoid floats
authorDaniel Stenberg <daniel@haxx.se>
Tue, 31 Aug 2021 12:09:28 +0000 (14:09 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 1 Sep 2021 06:35:31 +0000 (08:35 +0200)
and compiler warnings for data conversions.

Reported-by: MichaƂ Antoniak
Fixes #7645
Closes #7653

lib/progress.c

index 62e61d45b4557dbd0276b6b91542cc062085cfa2..f5ef6bd5269af449c190e24a7a89ce492dbe7d1e 100644 (file)
@@ -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 */