compiler warning fix

This commit is contained in:
Yang Tse 2007-02-01 01:42:13 +00:00
parent 5565f45f5e
commit 54db98c220
8 changed files with 36 additions and 23 deletions

View File

@ -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) static char *ares_striendstr(const char *s1, const char *s2)
{ {
const char *c1, *c2, *c1_begin; const char *c1, *c2, *c1_begin;
int lo1, lo2;
size_t s1_len = strlen(s1), s2_len = strlen(s2); size_t s1_len = strlen(s1), s2_len = strlen(s2);
/* If the substr is longer than the full str, it can't match */ /* 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; c2 = s2;
while (c2 < s2+s2_len) while (c2 < s2+s2_len)
{ {
if (tolower(*c1) != tolower(*c2)) lo1 = tolower(*c1);
lo2 = tolower(*c2);
if (lo1 != lo2)
return NULL; return NULL;
else else
{ {

View File

@ -181,7 +181,7 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
*/ */
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
channel->next_id = (unsigned short) channel->next_id = (unsigned short)
(tv.tv_sec ^ tv.tv_usec ^ getpid()) & 0xffff; ((tv.tv_sec ^ tv.tv_usec ^ getpid()) & 0xffff);
channel->queries = NULL; channel->queries = NULL;
@ -893,7 +893,7 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
sizeof(pat.addr.addr6))) > 0) sizeof(pat.addr.addr6))) > 0)
{ {
pat.type = PATTERN_CIDR; pat.type = PATTERN_CIDR;
pat.mask.bits = bits; pat.mask.bits = (unsigned short)bits;
pat.family = AF_INET6; pat.family = AF_INET6;
if (!sortlist_alloc(sortlist, nsort, &pat)) if (!sortlist_alloc(sortlist, nsort, &pat))
return ARES_ENOMEM; return ARES_ENOMEM;
@ -903,7 +903,7 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
sizeof(pat.addr.addr4))) > 0) sizeof(pat.addr.addr4))) > 0)
{ {
pat.type = PATTERN_CIDR; pat.type = PATTERN_CIDR;
pat.mask.bits = bits; pat.mask.bits = (unsigned short)bits;
pat.family = AF_INET; pat.family = AF_INET;
if (!sortlist_alloc(sortlist, nsort, &pat)) if (!sortlist_alloc(sortlist, nsort, &pat))
return ARES_ENOMEM; return ARES_ENOMEM;

View File

@ -141,7 +141,7 @@ int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
return ARES_EBADNAME; return ARES_EBADNAME;
/* Encode the length and copy the data. */ /* Encode the length and copy the data. */
*q++ = len; *q++ = (unsigned char)len;
for (p = name; *p && *p != '.'; p++) for (p = name; *p && *p != '.'; p++)
{ {
if (*p == '\\' && *(p + 1) != 0) if (*p == '\\' && *(p + 1) != 0)

View File

@ -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 /* Form the TCP query buffer by prepending qlen (as two
* network-order bytes) to qbuf. * network-order bytes) to qbuf.
*/ */
query->tcpbuf[0] = (qlen >> 8) & 0xff; query->tcpbuf[0] = (unsigned char)((qlen >> 8) & 0xff);
query->tcpbuf[1] = qlen & 0xff; query->tcpbuf[1] = (unsigned char)(qlen & 0xff);
memcpy(query->tcpbuf + 2, qbuf, qlen); memcpy(query->tcpbuf + 2, qbuf, qlen);
query->tcplen = qlen + 2; query->tcplen = qlen + 2;

View File

@ -252,7 +252,7 @@ getv4(const char *src, unsigned char *dst, int *bitsp)
if (ch == '.' || ch == '/') { if (ch == '.' || ch == '/') {
if (dst - odst > 3) /* too many octets? */ if (dst - odst > 3) /* too many octets? */
return (0); return (0);
*dst++ = val; *dst++ = (unsigned char)val;
if (ch == '/') if (ch == '/')
return (getbits(src, bitsp)); return (getbits(src, bitsp));
val = 0; val = 0;
@ -265,7 +265,7 @@ getv4(const char *src, unsigned char *dst, int *bitsp)
return (0); return (0);
if (dst - odst > 3) /* too many octets? */ if (dst - odst > 3) /* too many octets? */
return (0); return (0);
*dst++ = val; *dst++ = (unsigned char)val;
return (1); return (1);
} }
@ -321,8 +321,8 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size)
goto enoent; goto enoent;
if (tp + NS_INT16SZ > endp) if (tp + NS_INT16SZ > endp)
return (0); return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff; *tp++ = (unsigned char)((val >> 8) & 0xff);
*tp++ = (unsigned char) val & 0xff; *tp++ = (unsigned char)(val & 0xff);
saw_xdigit = 0; saw_xdigit = 0;
digits = 0; digits = 0;
val = 0; val = 0;
@ -342,8 +342,8 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size)
if (saw_xdigit) { if (saw_xdigit) {
if (tp + NS_INT16SZ > endp) if (tp + NS_INT16SZ > endp)
goto enoent; goto enoent;
*tp++ = (unsigned char) (val >> 8) & 0xff; *tp++ = (unsigned char)((val >> 8) & 0xff);
*tp++ = (unsigned char) val & 0xff; *tp++ = (unsigned char)(val & 0xff);
} }
if (bits == -1) if (bits == -1)
bits = 128; bits = 128;

View File

@ -3208,7 +3208,7 @@ static CURLcode ftp_nb_type(struct connectdata *conn,
state(conn, newstate); state(conn, newstate);
/* keep track of our current transfer type */ /* keep track of our current transfer type */
ftpc->transfertype = want; ftpc->transfertype = (char)want;
return CURLE_OK; return CURLE_OK;
} }

View File

@ -694,7 +694,7 @@ static int dprintf_formatf(
else else
prec = -1; prec = -1;
alt = (p->flags & FLAGS_ALT)?TRUE:FALSE; alt = (char)((p->flags & FLAGS_ALT)?TRUE:FALSE);
switch (p->type) { switch (p->type) {
case FORMAT_INT: case FORMAT_INT:
@ -734,14 +734,14 @@ static int dprintf_formatf(
#ifdef ENABLE_64BIT #ifdef ENABLE_64BIT
if(p->flags & FLAGS_LONGLONG) { if(p->flags & FLAGS_LONGLONG) {
/* long long */ /* long long */
is_neg = p->data.lnum < 0; is_neg = (char)(p->data.lnum < 0);
num = is_neg ? (- p->data.lnum) : p->data.lnum; num = is_neg ? (- p->data.lnum) : p->data.lnum;
} }
else else
#endif #endif
{ {
signed_num = (long) num; signed_num = (long) num;
is_neg = signed_num < 0; is_neg = (char)(signed_num < 0);
num = is_neg ? (- signed_num) : signed_num; num = is_neg ? (- signed_num) : signed_num;
} }
goto number; goto number;
@ -944,9 +944,9 @@ static int dprintf_formatf(
*fptr++ = 'l'; *fptr++ = 'l';
if (p->flags & FLAGS_FLOATE) if (p->flags & FLAGS_FLOATE)
*fptr++ = p->flags&FLAGS_UPPER ? 'E':'e'; *fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'E':'e');
else if (p->flags & FLAGS_FLOATG) else if (p->flags & FLAGS_FLOATG)
*fptr++ = p->flags & FLAGS_UPPER ? 'G' : 'g'; *fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'G' : 'g');
else else
*fptr++ = 'f'; *fptr++ = 'f';

View File

@ -375,19 +375,29 @@ CURLcode Curl_close(struct SessionHandle *data)
/* create a connection cache of a private or multi type */ /* create a connection cache of a private or multi type */
struct conncache *Curl_mk_connc(int type, struct conncache *Curl_mk_connc(int type,
int amount) /* set -1 to use default */ long amount) /* set -1 to use default */
{ {
/* It is subject for debate how many default connections to have for a multi /* It is subject for debate how many default connections to have for a multi
connection cache... */ connection cache... */
int default_amount = amount == -1?
((type == CONNCACHE_PRIVATE)?5:10):amount;
struct conncache *c; struct conncache *c;
long default_amount;
if (type == CONNCACHE_PRIVATE) {
default_amount = (amount < 0) ? 5 : amount;
}
else {
default_amount = (amount < 0) ? 10 : amount;
}
c= calloc(sizeof(struct conncache), 1); c= calloc(sizeof(struct conncache), 1);
if(!c) if(!c)
return NULL; return NULL;
c->connects = calloc(sizeof(struct connectdata *), default_amount); if ((size_t)(default_amount) > ((size_t)-1) / sizeof(struct connectdata *))
default_amount = ((size_t)-1) / sizeof(struct connectdata *);
c->connects = calloc(sizeof(struct connectdata *), (size_t)default_amount);
if(!c->connects) { if(!c->connects) {
free(c); free(c);
return NULL; return NULL;