From 8ab22a74533acee61af31c48e75269822f408cb4 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sat, 20 May 2017 19:39:51 +0200 Subject: time: fix type conversions and compiler warnings Fix bugs and compiler warnings on systems with 32-bit long and 64-bit time_t. Reviewed-by: Daniel Stenberg Closes #1499 --- lib/asyn-ares.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/asyn-ares.c') diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index 12f35e412..fb3d3fec0 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -373,7 +373,6 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, /* Wait for the name resolve query to complete. */ while(!result) { struct timeval *tvp, tv, store; - long timediff; int itimeout; int timeout_ms; @@ -402,8 +401,13 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, result = CURLE_ABORTED_BY_CALLBACK; else { struct timeval now2 = Curl_tvnow(); - timediff = Curl_tvdiff(now2, now); /* spent time */ - timeout -= timediff?timediff:1; /* always deduct at least 1 */ + time_t timediff = Curl_tvdiff(now2, now); /* spent time */ + if(timediff <= 0) + timeout -= 1; /* always deduct at least 1 */ + else if(timediff > timeout) + timeout = -1; + else + timeout -= (long)timediff; now = now2; /* for next loop */ } if(timeout < 0) -- cgit v1.2.3