Enabled a few more gcc warnings with --enable-debug. Renamed a few

variables to avoid shadowing global declarations.
This commit is contained in:
Dan Fandrich 2007-09-27 01:45:22 +00:00
parent 9c5cd6c413
commit 16b95fc773
16 changed files with 102 additions and 98 deletions

View File

@ -6,6 +6,10 @@
Changelog
Dan F (26 September 2007)
- Enabled a few more gcc warnings with --enable-debug. Renamed a few
variables to avoid shadowing global declarations.
Daniel S (26 September 2007)
- Philip Langdale provided the new CURLOPT_POST301 option for
curl_easy_setopt() that alters how libcurl functions when following

View File

@ -1762,7 +1762,7 @@ AC_DEFUN([CURL_CC_DEBUG_OPTS],
dnl only if the compiler is newer than 2.95 since we got lots of
dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
dnl gcc 2.95.4 on FreeBSD 4.9!
WARN="$WARN -Wundef -Wno-long-long -Wsign-compare"
WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
fi
if test "$gccnum" -ge "296"; then

View File

@ -373,12 +373,12 @@ CURLcode Curl_file(struct connectdata *conn, bool *done)
if(fstated) {
const struct tm *tm;
time_t clock = (time_t)statbuf.st_mtime;
time_t filetime = (time_t)statbuf.st_mtime;
#ifdef HAVE_GMTIME_R
struct tm buffer;
tm = (const struct tm *)gmtime_r(&clock, &buffer);
tm = (const struct tm *)gmtime_r(&filetime, &buffer);
#else
tm = gmtime(&clock);
tm = gmtime(&filetime);
#endif
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
snprintf(buf, BUFSIZE-1,

View File

@ -950,21 +950,21 @@ int curl_formget(struct curl_httppost *form, void *arg,
for (ptr = data; ptr; ptr = ptr->next) {
if (ptr->type == FORM_FILE) {
char buffer[8192];
size_t read;
size_t nread;
struct Form temp;
Curl_FormInit(&temp, ptr);
do {
read = readfromfile(&temp, buffer, sizeof(buffer));
if ((read == (size_t) -1) || (read != append(arg, buffer, read))) {
nread = readfromfile(&temp, buffer, sizeof(buffer));
if ((nread == (size_t) -1) || (nread != append(arg, buffer, nread))) {
if (temp.fp) {
fclose(temp.fp);
}
Curl_formclean(&data);
return -1;
}
} while (read == sizeof(buffer));
} while (nread == sizeof(buffer));
} else {
if (ptr->length != append(arg, ptr->line, ptr->length)) {
Curl_formclean(&data);

View File

@ -633,7 +633,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
/* This is the ONLY way to change FTP state! */
static void state(struct connectdata *conn,
ftpstate state)
ftpstate newstate)
{
#if defined(CURLDEBUG) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
/* for debug purposes */
@ -674,11 +674,11 @@ static void state(struct connectdata *conn,
#endif
struct ftp_conn *ftpc = &conn->proto.ftpc;
#if defined(CURLDEBUG) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
if(ftpc->state != state)
if(ftpc->state != newstate)
infof(conn->data, "FTP %p state change from %s to %s\n",
ftpc, names[ftpc->state], names[state]);
ftpc, names[ftpc->state], names[newstate]);
#endif
ftpc->state = state;
ftpc->state = newstate;
}
static CURLcode ftp_state_user(struct connectdata *conn)
@ -1882,12 +1882,12 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
data->set.get_filetime &&
(data->info.filetime>=0) ) {
struct tm *tm;
time_t clock = (time_t)data->info.filetime;
time_t filetime = (time_t)data->info.filetime;
#ifdef HAVE_GMTIME_R
struct tm buffer;
tm = (struct tm *)gmtime_r(&clock, &buffer);
tm = (struct tm *)gmtime_r(&filetime, &buffer);
#else
tm = gmtime(&clock);
tm = gmtime(&filetime);
#endif
/* format: "Tue, 15 Nov 1994 12:45:26" */
snprintf(buf, BUFSIZE-1,

View File

@ -443,11 +443,11 @@ static CURLcode mk_nt_hash(struct SessionHandle *data,
{
/* Create NT hashed password. */
MD4_CTX MD4;
MD4_CTX MD4pw;
MD4_Init(&MD4);
MD4_Update(&MD4, pw, 2*len);
MD4_Final(ntbuffer, &MD4);
MD4_Init(&MD4pw);
MD4_Update(&MD4pw, pw, 2*len);
MD4_Final(ntbuffer, &MD4pw);
memset(ntbuffer + 16, 0, 21 - 16);
}
@ -857,25 +857,25 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
unsigned char ntbuffer[0x18];
unsigned char tmp[0x18];
unsigned char md5sum[MD5_DIGEST_LENGTH];
MD5_CTX MD5;
unsigned char random[8];
MD5_CTX MD5pw;
unsigned char entropy[8];
/* Need to create 8 bytes random data */
Curl_ossl_seed(conn->data); /* Initiate the seed if not already done */
RAND_bytes(random,8);
RAND_bytes(entropy,8);
/* 8 bytes random data as challenge in lmresp */
memcpy(lmresp,random,8);
memcpy(lmresp,entropy,8);
/* Pad with zeros */
memset(lmresp+8,0,0x10);
/* Fill tmp with challenge(nonce?) + random */
/* Fill tmp with challenge(nonce?) + entropy */
memcpy(tmp,&ntlm->nonce[0],8);
memcpy(tmp+8,random,8);
memcpy(tmp+8,entropy,8);
MD5_Init(&MD5);
MD5_Update(&MD5, tmp, 16);
MD5_Final(md5sum, &MD5);
MD5_Init(&MD5pw);
MD5_Update(&MD5pw, tmp, 16);
MD5_Final(md5sum, &MD5pw);
/* We shall only use the first 8 bytes of md5sum,
but the des code in lm_resp only encrypt the first 8 bytes */
if (mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)

View File

@ -218,7 +218,7 @@ void curl_multi_dump(CURLM *multi_handle);
static void multistate(struct Curl_one_easy *easy, CURLMstate state)
{
#ifdef CURLDEBUG
long index = -5000;
long connectindex = -5000;
#endif
CURLMstate oldstate = easy->state;
@ -231,12 +231,12 @@ static void multistate(struct Curl_one_easy *easy, CURLMstate state)
#ifdef CURLDEBUG
if(easy->state > CURLM_STATE_CONNECT &&
easy->state < CURLM_STATE_COMPLETED)
index = easy->easy_conn->connectindex;
connectindex = easy->easy_conn->connectindex;
infof(easy->easy_handle,
"STATE: %s => %s handle %p; (connection #%ld) \n",
statename[oldstate], statename[easy->state],
(char *)easy, index);
(char *)easy, connectindex);
#endif
if(state == CURLM_STATE_COMPLETED)
/* changing to COMPLETED means there's one less easy handle 'alive' */

View File

@ -93,10 +93,10 @@ struct curl_slist *curl_slist_append(struct curl_slist *list,
new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist));
if (new_item) {
char *dup = strdup(data);
if(dup) {
char *dupdata = strdup(data);
if(dupdata) {
new_item->next = NULL;
new_item->data = dup;
new_item->data = dupdata;
}
else {
free(new_item);

View File

@ -260,34 +260,34 @@ struct Curl_tree *Curl_splaygetbest(int i, struct Curl_tree *t,
'newroot' will be made to point to NULL.
*/
int Curl_splayremovebyaddr(struct Curl_tree *t,
struct Curl_tree *remove,
struct Curl_tree *removenode,
struct Curl_tree **newroot)
{
struct Curl_tree *x;
if (!t || !remove)
if (!t || !removenode)
return 1;
if(KEY_NOTUSED == remove->key) {
if(KEY_NOTUSED == removenode->key) {
/* Key set to NOTUSED means it is a subnode within a 'same' linked list
and thus we can unlink it easily. The 'smaller' link of a subnode
links to the parent node. */
if (remove->smaller == NULL)
if (removenode->smaller == NULL)
return 3;
remove->smaller->same = remove->same;
if(remove->same)
remove->same->smaller = remove->smaller;
removenode->smaller->same = removenode->same;
if(removenode->same)
removenode->same->smaller = removenode->smaller;
/* Ensures that double-remove gets caught. */
remove->smaller = NULL;
removenode->smaller = NULL;
/* voila, we're done! */
*newroot = t; /* return the same root */
return 0;
}
t = Curl_splay(remove->key, t);
t = Curl_splay(removenode->key, t);
/* First make sure that we got the same root node as the one we want
to remove, as otherwise we might be trying to remove a node that
@ -296,7 +296,7 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
We cannot just compare the keys here as a double remove in quick
succession of a node with key != KEY_NOTUSED && same != NULL
could return the same key but a different node. */
if(t != remove)
if(t != removenode)
return 2;
/* Check if there is a list with identical sizes, as then we're trying to
@ -315,7 +315,7 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
if (t->smaller == NULL)
x = t->larger;
else {
x = Curl_splay(remove->key, t->smaller);
x = Curl_splay(removenode->key, t->smaller);
x->larger = t->larger;
}
}

View File

@ -42,7 +42,7 @@ struct Curl_tree *Curl_splayremove(int key, struct Curl_tree *t,
struct Curl_tree *Curl_splaygetbest(int key, struct Curl_tree *t,
struct Curl_tree **removed);
int Curl_splayremovebyaddr(struct Curl_tree *t,
struct Curl_tree *remove,
struct Curl_tree *removenode,
struct Curl_tree **newroot);
#ifdef CURLDEBUG

View File

@ -1750,15 +1750,15 @@ int Curl_single_getsock(const struct connectdata *conn,
{
const struct SessionHandle *data = conn->data;
int bitmap = GETSOCK_BLANK;
unsigned index = 0;
unsigned sockindex = 0;
if(numsocks < 2)
/* simple check but we might need two slots */
return GETSOCK_BLANK;
if(data->reqdata.keep.keepon & KEEP_READ) {
bitmap |= GETSOCK_READSOCK(index);
sock[index] = conn->sockfd;
bitmap |= GETSOCK_READSOCK(sockindex);
sock[sockindex] = conn->sockfd;
}
if(data->reqdata.keep.keepon & KEEP_WRITE) {
@ -1768,11 +1768,11 @@ int Curl_single_getsock(const struct connectdata *conn,
/* only if they are not the same socket or we didn't have a readable
one, we increase index */
if(data->reqdata.keep.keepon & KEEP_READ)
index++; /* increase index if we need two entries */
sock[index] = conn->writesockfd;
sockindex++; /* increase index if we need two entries */
sock[sockindex] = conn->writesockfd;
}
bitmap |= GETSOCK_WRITESOCK(index);
bitmap |= GETSOCK_WRITESOCK(sockindex);
}
return bitmap;

View File

@ -161,9 +161,9 @@ static bool IsPipeliningPossible(const struct SessionHandle *handle);
static bool IsPipeliningEnabled(const struct SessionHandle *handle);
static void conn_free(struct connectdata *conn);
static void signalPipeClose(struct curl_llist *pipe);
static void signalPipeClose(struct curl_llist *pipeline);
static struct SessionHandle* gethandleathead(struct curl_llist *pipe);
static struct SessionHandle* gethandleathead(struct curl_llist *pipeline);
#define MAX_PIPELINE_LENGTH 5
@ -292,7 +292,7 @@ CURLcode Curl_close(struct SessionHandle *data)
if(data->state.connc && data->state.connc->type == CONNCACHE_MULTI) {
struct conncache *c = data->state.connc;
long i;
struct curl_llist *pipe;
struct curl_llist *pipeline;
struct curl_llist_element *curr;
struct connectdata *connptr;
@ -301,9 +301,9 @@ CURLcode Curl_close(struct SessionHandle *data)
if(!connptr)
continue;
pipe = connptr->send_pipe;
if(pipe) {
for (curr = pipe->head; curr; curr=curr->next) {
pipeline = connptr->send_pipe;
if(pipeline) {
for (curr = pipeline->head; curr; curr=curr->next) {
if(data == (struct SessionHandle *) curr->ptr) {
fprintf(stderr,
"MAJOR problem we %p are still in send pipe for %p done %d\n",
@ -311,9 +311,9 @@ CURLcode Curl_close(struct SessionHandle *data)
}
}
}
pipe = connptr->recv_pipe;
if(pipe) {
for (curr = pipe->head; curr; curr=curr->next) {
pipeline = connptr->recv_pipe;
if(pipeline) {
for (curr = pipeline->head; curr; curr=curr->next) {
if(data == (struct SessionHandle *) curr->ptr) {
fprintf(stderr,
"MAJOR problem we %p are still in recv pipe for %p done %d\n",
@ -2036,30 +2036,30 @@ static bool IsPipeliningEnabled(const struct SessionHandle *handle)
}
CURLcode Curl_addHandleToPipeline(struct SessionHandle *data,
struct curl_llist *pipe)
struct curl_llist *pipeline)
{
#ifdef CURLDEBUG
if(!IsPipeliningPossible(data)) {
/* when not pipelined, there MUST be no handle in the list already */
if(pipe->head)
if(pipeline->head)
infof(data, "PIPE when no PIPE supposed!\n");
}
#endif
if (!Curl_llist_insert_next(pipe, pipe->tail, data))
if (!Curl_llist_insert_next(pipeline, pipeline->tail, data))
return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
}
int Curl_removeHandleFromPipeline(struct SessionHandle *handle,
struct curl_llist *pipe)
struct curl_llist *pipeline)
{
struct curl_llist_element *curr;
curr = pipe->head;
curr = pipeline->head;
while (curr) {
if (curr->ptr == handle) {
Curl_llist_remove(pipe, curr, NULL);
Curl_llist_remove(pipeline, curr, NULL);
return 1; /* we removed a handle */
}
curr = curr->next;
@ -2069,11 +2069,11 @@ int Curl_removeHandleFromPipeline(struct SessionHandle *handle,
}
#if 0 /* this code is saved here as it is useful for debugging purposes */
static void Curl_printPipeline(struct curl_llist *pipe)
static void Curl_printPipeline(struct curl_llist *pipeline)
{
struct curl_llist_element *curr;
curr = pipe->head;
curr = pipeline->head;
while (curr) {
struct SessionHandle *data = (struct SessionHandle *) curr->ptr;
infof(data, "Handle in pipeline: %s\n", data->reqdata.path);
@ -2083,9 +2083,9 @@ static void Curl_printPipeline(struct curl_llist *pipe)
#endif
bool Curl_isHandleAtHead(struct SessionHandle *handle,
struct curl_llist *pipe)
struct curl_llist *pipeline)
{
struct curl_llist_element *curr = pipe->head;
struct curl_llist_element *curr = pipeline->head;
if (curr) {
return (bool)(curr->ptr == handle);
}
@ -2093,9 +2093,9 @@ bool Curl_isHandleAtHead(struct SessionHandle *handle,
return FALSE;
}
static struct SessionHandle* gethandleathead(struct curl_llist *pipe)
static struct SessionHandle* gethandleathead(struct curl_llist *pipeline)
{
struct curl_llist_element *curr = pipe->head;
struct curl_llist_element *curr = pipeline->head;
if (curr) {
return (struct SessionHandle *) curr->ptr;
}
@ -2103,14 +2103,14 @@ static struct SessionHandle* gethandleathead(struct curl_llist *pipe)
return NULL;
}
static void signalPipeClose(struct curl_llist *pipe)
static void signalPipeClose(struct curl_llist *pipeline)
{
struct curl_llist_element *curr;
if (!pipe)
if (!pipeline)
return;
curr = pipe->head;
curr = pipeline->head;
while (curr) {
struct curl_llist_element *next = curr->next;
struct SessionHandle *data = (struct SessionHandle *) curr->ptr;
@ -2124,7 +2124,7 @@ static void signalPipeClose(struct curl_llist *pipe)
data->state.pipe_broke = TRUE;
Curl_multi_handlePipeBreak(data);
Curl_llist_remove(pipe, curr, NULL);
Curl_llist_remove(pipeline, curr, NULL);
curr = next;
}
}

View File

@ -65,11 +65,11 @@ int Curl_doing_getsock(struct connectdata *conn,
int numsocks);
CURLcode Curl_addHandleToPipeline(struct SessionHandle *handle,
struct curl_llist *pipe);
struct curl_llist *pipeline);
int Curl_removeHandleFromPipeline(struct SessionHandle *handle,
struct curl_llist *pipe);
struct curl_llist *pipeline);
bool Curl_isHandleAtHead(struct SessionHandle *handle,
struct curl_llist *pipe);
struct curl_llist *pipeline);
void Curl_close_connections(struct SessionHandle *data);

View File

@ -31,14 +31,14 @@ struct userdata {
};
/* lock callback */
static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access access,
static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess,
void *useptr )
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
(void)handle;
(void)access;
(void)laccess;
switch ( data ) {
case CURL_LOCK_DATA_SHARE:

View File

@ -411,7 +411,7 @@ static int juggle(curl_socket_t *sockfdp,
}
static curl_socket_t sockdaemon(curl_socket_t sock,
unsigned short *port)
unsigned short *listenport)
{
/* passive daemon style */
struct sockaddr_in me;
@ -441,7 +441,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
#endif
me.sin_family = AF_INET;
me.sin_addr.s_addr = INADDR_ANY;
me.sin_port = htons(*port);
me.sin_port = htons(*listenport);
rc = bind(sock, (struct sockaddr *) &me, sizeof(me));
#ifdef ENABLE_IPV6
}
@ -449,7 +449,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
memset(&me6, 0, sizeof(struct sockaddr_in6));
me6.sin6_family = AF_INET6;
me6.sin6_addr = in6addr_any;
me6.sin6_port = htons(*port);
me6.sin6_port = htons(*listenport);
rc = bind(sock, (struct sockaddr *) &me6, sizeof(me6));
}
#endif /* ENABLE_IPV6 */
@ -459,7 +459,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
return CURL_SOCKET_BAD;
}
if(!*port) {
if(!*listenport) {
/* The system picked a port number, now figure out which port we actually
got */
/* we succeeded to bind */
@ -471,7 +471,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
logmsg("getsockname() failed with error: %d", SOCKERRNO);
return CURL_SOCKET_BAD;
}
*port = ntohs(add.sin_port);
*listenport = ntohs(add.sin_port);
}
/* start accepting connections */
@ -485,13 +485,13 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
return sock;
}
static curl_socket_t mksock(bool use_ipv6)
static curl_socket_t mksock(bool ipv6)
{
curl_socket_t sock;
#ifdef ENABLE_IPV6
if(!use_ipv6)
if(!ipv6)
#else
(void)use_ipv6;
(void)ipv6;
#endif
sock = socket(AF_INET, SOCK_STREAM, 0);
#ifdef ENABLE_IPV6

View File

@ -286,7 +286,7 @@ static int writeit(struct testcase *test, struct tftphdr **dpp,
*/
static ssize_t write_behind(struct testcase *test, int convert)
{
char *buf;
char *writebuf;
int count;
int ct;
char *p;
@ -312,15 +312,15 @@ static ssize_t write_behind(struct testcase *test, int convert)
b->counter = BF_FREE; /* reset flag */
dp = (struct tftphdr *)b->buf;
nextone = !nextone; /* incr for next time */
buf = dp->th_data;
writebuf = dp->th_data;
if (count <= 0)
return -1; /* nak logic? */
if (convert == 0)
return write(test->ofile, buf, count);
return write(test->ofile, writebuf, count);
p = buf;
p = writebuf;
ct = count;
while (ct--) { /* loop over the buffer */
c = *p++; /* pick up a character */
@ -363,8 +363,8 @@ static int synchnet(curl_socket_t f /* socket to flush */)
#endif
int j = 0;
char rbuf[PKTSIZE];
struct sockaddr_in from;
socklen_t fromlen;
struct sockaddr_in fromaddr;
socklen_t fromaddrlen;
while (1) {
#if defined(HAVE_IOCTLSOCKET)
@ -374,9 +374,9 @@ static int synchnet(curl_socket_t f /* socket to flush */)
#endif
if (i) {
j++;
fromlen = sizeof from;
fromaddrlen = sizeof fromaddr;
(void) recvfrom(f, rbuf, sizeof (rbuf), 0,
(struct sockaddr *)&from, &fromlen);
(struct sockaddr *)&fromaddr, &fromaddrlen);
}
else
break;