summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarc Hoersken <info@marc-hoersken.de>2020-06-01 08:49:20 +0200
committerMarc Hoersken <info@marc-hoersken.de>2020-06-06 20:05:58 +0200
commit3186f5005497df68ef0735b2e23b8a5c9d76d8b9 (patch)
tree6b75126d0db7d338d5e4792a1bc03f4124c051d2 /lib
parente2de2d53979ac6d93303562f5531f75944e70b8b (diff)
downloadcurl-3186f5005497df68ef0735b2e23b8a5c9d76d8b9.tar.gz
timeouts: move ms timeouts to timediff_t from int and long
Now that all functions in select.[ch] take timediff_t instead of the limited int or long, we can remove type conversions and related preprocessor checks to silence compiler warnings. Avoiding conversions from time_t was already done in 842f73de. Based upon #5262 Supersedes #5214, #5220 and #5221 Follow up to #5343 and #5479 Closes #5490
Diffstat (limited to 'lib')
-rw-r--r--lib/asyn-ares.c14
-rw-r--r--lib/easy.c2
-rw-r--r--lib/multi.c2
-rw-r--r--lib/socks.c2
-rw-r--r--lib/telnet.c2
5 files changed, 13 insertions, 9 deletions
diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c
index faabe1595..ba5160b25 100644
--- a/lib/asyn-ares.c
+++ b/lib/asyn-ares.c
@@ -286,7 +286,7 @@ int Curl_resolver_getsock(struct connectdata *conn,
* return number of sockets it worked on
*/
-static int waitperform(struct connectdata *conn, int timeout_ms)
+static int waitperform(struct connectdata *conn, timediff_t timeout_ms)
{
struct Curl_easy *data = conn->data;
int nfds;
@@ -437,9 +437,13 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
while(!result) {
struct timeval *tvp, tv, store;
int itimeout;
- int timeout_ms;
+ timediff_t timeout_ms;
- itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
+#if TIMEDIFF_T_MAX > INT_MAX
+ itimeout = (timeout > INT_MAX) ? INT_MAX : (int)timeout;
+#else
+ itimeout = (int)timeout;
+#endif
store.tv_sec = itimeout/1000;
store.tv_usec = (itimeout%1000)*1000;
@@ -450,7 +454,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
second is left, otherwise just use 1000ms to make sure the progress
callback gets called frequent enough */
if(!tvp->tv_sec)
- timeout_ms = (int)(tvp->tv_usec/1000);
+ timeout_ms = (timediff_t)(tvp->tv_usec/1000);
else
timeout_ms = 1000;
@@ -470,7 +474,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
else if(timediff > timeout)
timeout = -1;
else
- timeout -= (long)timediff;
+ timeout -= timediff;
now = now2; /* for next loop */
}
if(timeout < 0)
diff --git a/lib/easy.c b/lib/easy.c
index f58c4521a..292cca7f6 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -510,7 +510,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
before = Curl_now();
/* wait for activity or timeout */
- pollrc = Curl_poll(fds, numfds, (int)ev->ms);
+ pollrc = Curl_poll(fds, numfds, ev->ms);
after = Curl_now();
diff --git a/lib/multi.c b/lib/multi.c
index 0a45ef4b6..a614929ec 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1255,7 +1255,7 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
timeout */
else if((sleep_ms < 0) && extrawait)
sleep_ms = timeout_ms;
- Curl_wait_ms((int)sleep_ms);
+ Curl_wait_ms(sleep_ms);
}
}
diff --git a/lib/socks.c b/lib/socks.c
index 98b7818d8..93b052cf0 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -69,7 +69,7 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
break;
}
if(!timeout_ms)
- timeout_ms = TIME_T_MAX;
+ timeout_ms = TIMEDIFF_T_MAX;
if(SOCKET_READABLE(sockfd, timeout_ms) <= 0) {
result = ~CURLE_OK;
break;
diff --git a/lib/telnet.c b/lib/telnet.c
index 4bf4c652c..01394e1e3 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -1315,7 +1315,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
DWORD readfile_read;
int err;
#else
- int interval_ms;
+ timediff_t interval_ms;
struct pollfd pfd[2];
int poll_cnt;
curl_off_t total_dl = 0;