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/easy.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/easy.c') diff --git a/lib/easy.c b/lib/easy.c index 46c0a9911..2b1ce9e8a 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -615,12 +615,18 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev) } } - if(!ev->msbump) + if(!ev->msbump) { /* If nothing updated the timeout, we decrease it by the spent time. * If it was updated, it has the new timeout time stored already. */ - ev->ms += (long)curlx_tvdiff(after, before); - + time_t timediff = curlx_tvdiff(after, before); + if(timediff > 0) { + if(timediff > ev->ms) + ev->ms = 0; + else + ev->ms -= (long)timediff; + } + } } else return CURLE_RECV_ERROR; -- cgit v1.2.3