diff options
author | Yang Tse <yangsita@gmail.com> | 2012-12-10 16:12:49 +0100 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2012-12-10 16:12:49 +0100 |
commit | 98b52964cf0abf92dcaf71c203ff27af8a70a423 (patch) | |
tree | f145d6f44ab903bddc2976df43074fcebe661dbd | |
parent | 93a09eabebb0950dcf44d2513c9c60e71b00692a (diff) | |
download | c-ares-98b52964cf0abf92dcaf71c203ff27af8a70a423.tar.gz c-ares-98b52964cf0abf92dcaf71c203ff27af8a70a423.tar.bz2 c-ares-98b52964cf0abf92dcaf71c203ff27af8a70a423.zip |
ares_timeout.c: fix compiler warning
-rw-r--r-- | ares_timeout.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ares_timeout.c b/ares_timeout.c index 738ad15..1dc0283 100644 --- a/ares_timeout.c +++ b/ares_timeout.c @@ -16,6 +16,9 @@ #include "ares_setup.h" +#ifdef HAVE_LIMITS_H +#include <limits.h> +#endif #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -67,8 +70,10 @@ struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv, */ if (min_offset != -1) { - nextstop.tv_sec = min_offset/1000; - nextstop.tv_usec = (min_offset%1000)*1000; + int ioffset = (min_offset > (long)INT_MAX) ? INT_MAX : (int)min_offset; + + nextstop.tv_sec = ioffset/1000; + nextstop.tv_usec = (ioffset%1000)*1000; if (!maxtv || ares__timedout(maxtv, &nextstop)) { |