progress: make trspeed avoid floats

and compiler warnings for data conversions.

Reported-by: Michał Antoniak
Fixes #7645
Closes #7653
This commit is contained in:
Daniel Stenberg 2021-08-31 14:09:28 +02:00
parent e8c8775eaa
commit c905459e87
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View 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 */