From fb38ee15e249e187ffcbb91df82684a61783945c Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 1 Feb 2007 01:42:13 +0000 Subject: [PATCH] compiler warning fix --- ares_getnameinfo.c | 5 ++++- ares_init.c | 6 +++--- ares_mkquery.c | 2 +- ares_send.c | 4 ++-- inet_net_pton.c | 12 ++++++------ 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ares_getnameinfo.c b/ares_getnameinfo.c index 71cf41d..51e36fb 100644 --- a/ares_getnameinfo.c +++ b/ares_getnameinfo.c @@ -357,6 +357,7 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags, static char *ares_striendstr(const char *s1, const char *s2) { const char *c1, *c2, *c1_begin; + int lo1, lo2; size_t s1_len = strlen(s1), s2_len = strlen(s2); /* If the substr is longer than the full str, it can't match */ @@ -369,7 +370,9 @@ static char *ares_striendstr(const char *s1, const char *s2) c2 = s2; while (c2 < s2+s2_len) { - if (tolower(*c1) != tolower(*c2)) + lo1 = tolower(*c1); + lo2 = tolower(*c2); + if (lo1 != lo2) return NULL; else { diff --git a/ares_init.c b/ares_init.c index e32633f..e837190 100644 --- a/ares_init.c +++ b/ares_init.c @@ -181,7 +181,7 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options, */ gettimeofday(&tv, NULL); channel->next_id = (unsigned short) - (tv.tv_sec ^ tv.tv_usec ^ getpid()) & 0xffff; + ((tv.tv_sec ^ tv.tv_usec ^ getpid()) & 0xffff); channel->queries = NULL; @@ -893,7 +893,7 @@ static int config_sortlist(struct apattern **sortlist, int *nsort, sizeof(pat.addr.addr6))) > 0) { pat.type = PATTERN_CIDR; - pat.mask.bits = bits; + pat.mask.bits = (unsigned short)bits; pat.family = AF_INET6; if (!sortlist_alloc(sortlist, nsort, &pat)) return ARES_ENOMEM; @@ -903,7 +903,7 @@ static int config_sortlist(struct apattern **sortlist, int *nsort, sizeof(pat.addr.addr4))) > 0) { pat.type = PATTERN_CIDR; - pat.mask.bits = bits; + pat.mask.bits = (unsigned short)bits; pat.family = AF_INET; if (!sortlist_alloc(sortlist, nsort, &pat)) return ARES_ENOMEM; diff --git a/ares_mkquery.c b/ares_mkquery.c index e30abfc..11ce302 100644 --- a/ares_mkquery.c +++ b/ares_mkquery.c @@ -141,7 +141,7 @@ int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id, return ARES_EBADNAME; /* Encode the length and copy the data. */ - *q++ = len; + *q++ = (unsigned char)len; for (p = name; *p && *p != '.'; p++) { if (*p == '\\' && *(p + 1) != 0) diff --git a/ares_send.c b/ares_send.c index a279ee9..89efec0 100644 --- a/ares_send.c +++ b/ares_send.c @@ -79,8 +79,8 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen, /* Form the TCP query buffer by prepending qlen (as two * network-order bytes) to qbuf. */ - query->tcpbuf[0] = (qlen >> 8) & 0xff; - query->tcpbuf[1] = qlen & 0xff; + query->tcpbuf[0] = (unsigned char)((qlen >> 8) & 0xff); + query->tcpbuf[1] = (unsigned char)(qlen & 0xff); memcpy(query->tcpbuf + 2, qbuf, qlen); query->tcplen = qlen + 2; diff --git a/inet_net_pton.c b/inet_net_pton.c index ef96741..8c78a0b 100644 --- a/inet_net_pton.c +++ b/inet_net_pton.c @@ -252,7 +252,7 @@ getv4(const char *src, unsigned char *dst, int *bitsp) if (ch == '.' || ch == '/') { if (dst - odst > 3) /* too many octets? */ return (0); - *dst++ = val; + *dst++ = (unsigned char)val; if (ch == '/') return (getbits(src, bitsp)); val = 0; @@ -265,7 +265,7 @@ getv4(const char *src, unsigned char *dst, int *bitsp) return (0); if (dst - odst > 3) /* too many octets? */ return (0); - *dst++ = val; + *dst++ = (unsigned char)val; return (1); } @@ -321,8 +321,8 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) goto enoent; if (tp + NS_INT16SZ > endp) return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; + *tp++ = (unsigned char)((val >> 8) & 0xff); + *tp++ = (unsigned char)(val & 0xff); saw_xdigit = 0; digits = 0; val = 0; @@ -342,8 +342,8 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) if (saw_xdigit) { if (tp + NS_INT16SZ > endp) goto enoent; - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; + *tp++ = (unsigned char)((val >> 8) & 0xff); + *tp++ = (unsigned char)(val & 0xff); } if (bits == -1) bits = 128; -- 2.7.4