summaryrefslogtreecommitdiff
path: root/lib/progress.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-11-11 10:19:22 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-11-12 13:32:21 +0100
commitde4de4e3c7c4690393de384f81b6c094d9f5d553 (patch)
treeea50b347624888083bdd2f0417f98d50e5cfa70a /lib/progress.c
parent56bb7b1a3c17657a376a32f39eb7d2d15876a519 (diff)
downloadcurl-de4de4e3c7c4690393de384f81b6c094d9f5d553.tar.gz
timeval: prefer time_t to hold seconds instead of long
... as long is still 32bit on modern 64bit windows machines, while time_t is generally 64bit.
Diffstat (limited to 'lib/progress.c')
-rw-r--r--lib/progress.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/progress.c b/lib/progress.c
index 5a1a1ae9c..adbb737ed 100644
--- a/lib/progress.c
+++ b/lib/progress.c
@@ -249,24 +249,26 @@ long Curl_pgrsLimitWaitTime(curl_off_t cursize,
struct timeval start,
struct timeval now)
{
- curl_off_t size = cursize - startsize;
- long minimum, actual;
+ curl_off_t size = cursize - startsize;
+ size_t minimum;
+ size_t actual;
- /* we don't have a starting point yet -- return 0 so it gets (re)set */
- if(start.tv_sec == 0 && start.tv_usec == 0)
- return 0;
+ /* we don't have a starting point yet -- return 0 so it gets (re)set */
+ if(start.tv_sec == 0 && start.tv_usec == 0)
+ return 0;
- /* not enough data yet */
- if(size < limit)
- return -1;
+ /* not enough data yet */
+ if(size < limit)
+ return -1;
- minimum = (long) (CURL_OFF_T_C(1000) * size / limit);
- actual = Curl_tvdiff(now, start);
+ minimum = (time_t) (CURL_OFF_T_C(1000) * size / limit);
+ actual = Curl_tvdiff(now, start);
- if(actual < minimum)
- return minimum - actual;
- else
- return 0;
+ if(actual < minimum)
+ /* this is a conversion on some systems (64bit time_t => 32bit long) */
+ return (long)(minimum - actual);
+ else
+ return 0;
}
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
@@ -373,7 +375,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
(data->progress.timespent>0?data->progress.timespent:1));
/* Calculations done at most once a second, unless end is reached */
- if(data->progress.lastshow != (long)now.tv_sec) {
+ if(data->progress.lastshow != now.tv_sec) {
shownow = TRUE;
data->progress.lastshow = now.tv_sec;
@@ -400,7 +402,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
/* first of all, we don't do this if there's no counted seconds yet */
if(countindex) {
- long span_ms;
+ time_t span_ms;
/* Get the index position to compare with the 'nowindex' position.
Get the oldest entry possible. While we have less than CURR_TIME