summaryrefslogtreecommitdiff
path: root/lib/hostip.c
diff options
context:
space:
mode:
authorMichael Kaufmann <mail@michael-kaufmann.ch>2017-05-20 19:39:51 +0200
committerMichael Kaufmann <mail@michael-kaufmann.ch>2017-05-24 22:56:22 +0200
commit8ab22a74533acee61af31c48e75269822f408cb4 (patch)
tree24025f8450cf3b72eb5bf9316c1212b0a571363c /lib/hostip.c
parentb4d87f54d60711e936fefae388d741b281eecdf0 (diff)
downloadcurl-8ab22a74533acee61af31c48e75269822f408cb4.tar.gz
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
Diffstat (limited to 'lib/hostip.c')
-rw-r--r--lib/hostip.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/hostip.c b/lib/hostip.c
index 21baf6015..619ec84b5 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -596,7 +596,7 @@ int Curl_resolv_timeout(struct connectdata *conn,
/* Ignore the timeout when signals are disabled */
timeout = 0;
else
- timeout = timeoutms;
+ timeout = (timeoutms > LONG_MAX) ? LONG_MAX : (long)timeoutms;
if(!timeout)
/* USE_ALARM_TIMEOUT defined, but no timeout actually requested */
@@ -688,10 +688,11 @@ clean_up:
the time we spent until now! */
if(prev_alarm) {
/* there was an alarm() set before us, now put it back */
- unsigned long elapsed_ms = Curl_tvdiff(Curl_tvnow(), conn->created);
+ unsigned long elapsed_secs = (unsigned long) (Curl_tvdiff(Curl_tvnow(),
+ conn->created) / 1000);
/* the alarm period is counted in even number of seconds */
- unsigned long alarm_set = prev_alarm - elapsed_ms/1000;
+ unsigned long alarm_set = prev_alarm - elapsed_secs;
if(!alarm_set ||
((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000)) ) {