fix compiler warning
This commit is contained in:
parent
3ca0b9bb47
commit
4ea513cc38
@ -544,7 +544,7 @@ CURLcode curl_easy_perform(CURL *curl)
|
|||||||
|
|
||||||
if(!data->state.connc) {
|
if(!data->state.connc) {
|
||||||
/* oops, no connection cache, make one up */
|
/* oops, no connection cache, make one up */
|
||||||
data->state.connc = Curl_mk_connc(CONNCACHE_PRIVATE, -1);
|
data->state.connc = Curl_mk_connc(CONNCACHE_PRIVATE, -1L);
|
||||||
if(!data->state.connc)
|
if(!data->state.connc)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ CURLM *curl_multi_init(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
multi->connc = Curl_mk_connc(CONNCACHE_MULTI, -1);
|
multi->connc = Curl_mk_connc(CONNCACHE_MULTI, -1L);
|
||||||
if(!multi->connc) {
|
if(!multi->connc) {
|
||||||
Curl_hash_destroy(multi->sockhash);
|
Curl_hash_destroy(multi->sockhash);
|
||||||
Curl_hash_destroy(multi->hostcache);
|
Curl_hash_destroy(multi->hostcache);
|
||||||
|
18
lib/url.c
18
lib/url.c
@ -531,22 +531,23 @@ struct conncache *Curl_mk_connc(int type,
|
|||||||
|
|
||||||
struct conncache *c;
|
struct conncache *c;
|
||||||
long default_amount;
|
long default_amount;
|
||||||
|
long max_amount = (long)(((size_t)INT_MAX) / sizeof(struct connectdata *));
|
||||||
|
|
||||||
if(type == CONNCACHE_PRIVATE) {
|
if(type == CONNCACHE_PRIVATE) {
|
||||||
default_amount = (amount < 0) ? 5 : amount;
|
default_amount = (amount < 1L) ? 5L : amount;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
default_amount = (amount < 0) ? 10 : amount;
|
default_amount = (amount < 1L) ? 10L : amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
c= calloc(sizeof(struct conncache), 1);
|
if(default_amount > max_amount)
|
||||||
|
default_amount = max_amount;
|
||||||
|
|
||||||
|
c = calloc(1, sizeof(struct conncache));
|
||||||
if(!c)
|
if(!c)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if((size_t)(default_amount) > ((size_t)-1) / sizeof(struct connectdata *))
|
c->connects = calloc((size_t)default_amount, 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;
|
||||||
@ -564,6 +565,7 @@ CURLcode Curl_ch_connc(struct SessionHandle *data,
|
|||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
struct connectdata **newptr;
|
struct connectdata **newptr;
|
||||||
|
long max_amount = (long)(((size_t)INT_MAX) / sizeof(struct connectdata *));
|
||||||
|
|
||||||
if(newamount < 1)
|
if(newamount < 1)
|
||||||
newamount = 1; /* we better have at least one entry */
|
newamount = 1; /* we better have at least one entry */
|
||||||
@ -596,6 +598,8 @@ CURLcode Curl_ch_connc(struct SessionHandle *data,
|
|||||||
data->state.lastconnect = -1;
|
data->state.lastconnect = -1;
|
||||||
}
|
}
|
||||||
if(newamount > 0) {
|
if(newamount > 0) {
|
||||||
|
if(newamount > max_amount)
|
||||||
|
newamount = max_amount;
|
||||||
newptr = realloc(c->connects, sizeof(struct connectdata *) * newamount);
|
newptr = realloc(c->connects, sizeof(struct connectdata *) * newamount);
|
||||||
if(!newptr)
|
if(!newptr)
|
||||||
/* we closed a few connections in vain, but so what? */
|
/* we closed a few connections in vain, but so what? */
|
||||||
|
@ -453,7 +453,17 @@ static bool juggle(curl_socket_t *sockfdp,
|
|||||||
FD_ZERO(&fds_write);
|
FD_ZERO(&fds_write);
|
||||||
FD_ZERO(&fds_err);
|
FD_ZERO(&fds_err);
|
||||||
|
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
|
/*
|
||||||
|
** WinSock select() does not support standard file descriptors,
|
||||||
|
** it can only check SOCKETs. Since this program in its current
|
||||||
|
** state will not work on WinSock based systems, next line is
|
||||||
|
** commented out to allow warning-free compilation awaiting the
|
||||||
|
** day it will be fixed to also run on WinSock systems.
|
||||||
|
*/
|
||||||
|
#else
|
||||||
FD_SET(fileno(stdin), &fds_read);
|
FD_SET(fileno(stdin), &fds_read);
|
||||||
|
#endif
|
||||||
|
|
||||||
switch(*mode) {
|
switch(*mode) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user