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 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) Daniel S (26 September 2007)
- Philip Langdale provided the new CURLOPT_POST301 option for - Philip Langdale provided the new CURLOPT_POST301 option for
curl_easy_setopt() that alters how libcurl functions when following 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 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 "`_POSIX_C_SOURCE' is not defined" in system headers with
dnl gcc 2.95.4 on FreeBSD 4.9! 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 fi
if test "$gccnum" -ge "296"; then if test "$gccnum" -ge "296"; then

View File

@ -373,12 +373,12 @@ CURLcode Curl_file(struct connectdata *conn, bool *done)
if(fstated) { if(fstated) {
const struct tm *tm; const struct tm *tm;
time_t clock = (time_t)statbuf.st_mtime; time_t filetime = (time_t)statbuf.st_mtime;
#ifdef HAVE_GMTIME_R #ifdef HAVE_GMTIME_R
struct tm buffer; struct tm buffer;
tm = (const struct tm *)gmtime_r(&clock, &buffer); tm = (const struct tm *)gmtime_r(&filetime, &buffer);
#else #else
tm = gmtime(&clock); tm = gmtime(&filetime);
#endif #endif
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */ /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
snprintf(buf, BUFSIZE-1, 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) { for (ptr = data; ptr; ptr = ptr->next) {
if (ptr->type == FORM_FILE) { if (ptr->type == FORM_FILE) {
char buffer[8192]; char buffer[8192];
size_t read; size_t nread;
struct Form temp; struct Form temp;
Curl_FormInit(&temp, ptr); Curl_FormInit(&temp, ptr);
do { do {
read = readfromfile(&temp, buffer, sizeof(buffer)); nread = readfromfile(&temp, buffer, sizeof(buffer));
if ((read == (size_t) -1) || (read != append(arg, buffer, read))) { if ((nread == (size_t) -1) || (nread != append(arg, buffer, nread))) {
if (temp.fp) { if (temp.fp) {
fclose(temp.fp); fclose(temp.fp);
} }
Curl_formclean(&data); Curl_formclean(&data);
return -1; return -1;
} }
} while (read == sizeof(buffer)); } while (nread == sizeof(buffer));
} else { } else {
if (ptr->length != append(arg, ptr->line, ptr->length)) { if (ptr->length != append(arg, ptr->line, ptr->length)) {
Curl_formclean(&data); 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! */ /* This is the ONLY way to change FTP state! */
static void state(struct connectdata *conn, static void state(struct connectdata *conn,
ftpstate state) ftpstate newstate)
{ {
#if defined(CURLDEBUG) && !defined(CURL_DISABLE_VERBOSE_STRINGS) #if defined(CURLDEBUG) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
/* for debug purposes */ /* for debug purposes */
@ -674,11 +674,11 @@ static void state(struct connectdata *conn,
#endif #endif
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
#if defined(CURLDEBUG) && !defined(CURL_DISABLE_VERBOSE_STRINGS) #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", 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 #endif
ftpc->state = state; ftpc->state = newstate;
} }
static CURLcode ftp_state_user(struct connectdata *conn) 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->set.get_filetime &&
(data->info.filetime>=0) ) { (data->info.filetime>=0) ) {
struct tm *tm; struct tm *tm;
time_t clock = (time_t)data->info.filetime; time_t filetime = (time_t)data->info.filetime;
#ifdef HAVE_GMTIME_R #ifdef HAVE_GMTIME_R
struct tm buffer; struct tm buffer;
tm = (struct tm *)gmtime_r(&clock, &buffer); tm = (struct tm *)gmtime_r(&filetime, &buffer);
#else #else
tm = gmtime(&clock); tm = gmtime(&filetime);
#endif #endif
/* format: "Tue, 15 Nov 1994 12:45:26" */ /* format: "Tue, 15 Nov 1994 12:45:26" */
snprintf(buf, BUFSIZE-1, snprintf(buf, BUFSIZE-1,

View File

@ -443,11 +443,11 @@ static CURLcode mk_nt_hash(struct SessionHandle *data,
{ {
/* Create NT hashed password. */ /* Create NT hashed password. */
MD4_CTX MD4; MD4_CTX MD4pw;
MD4_Init(&MD4); MD4_Init(&MD4pw);
MD4_Update(&MD4, pw, 2*len); MD4_Update(&MD4pw, pw, 2*len);
MD4_Final(ntbuffer, &MD4); MD4_Final(ntbuffer, &MD4pw);
memset(ntbuffer + 16, 0, 21 - 16); memset(ntbuffer + 16, 0, 21 - 16);
} }
@ -857,25 +857,25 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
unsigned char ntbuffer[0x18]; unsigned char ntbuffer[0x18];
unsigned char tmp[0x18]; unsigned char tmp[0x18];
unsigned char md5sum[MD5_DIGEST_LENGTH]; unsigned char md5sum[MD5_DIGEST_LENGTH];
MD5_CTX MD5; MD5_CTX MD5pw;
unsigned char random[8]; unsigned char entropy[8];
/* Need to create 8 bytes random data */ /* Need to create 8 bytes random data */
Curl_ossl_seed(conn->data); /* Initiate the seed if not already done */ 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 */ /* 8 bytes random data as challenge in lmresp */
memcpy(lmresp,random,8); memcpy(lmresp,entropy,8);
/* Pad with zeros */ /* Pad with zeros */
memset(lmresp+8,0,0x10); 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,&ntlm->nonce[0],8);
memcpy(tmp+8,random,8); memcpy(tmp+8,entropy,8);
MD5_Init(&MD5); MD5_Init(&MD5pw);
MD5_Update(&MD5, tmp, 16); MD5_Update(&MD5pw, tmp, 16);
MD5_Final(md5sum, &MD5); MD5_Final(md5sum, &MD5pw);
/* We shall only use the first 8 bytes of md5sum, /* We shall only use the first 8 bytes of md5sum,
but the des code in lm_resp only encrypt the first 8 bytes */ 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) 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) static void multistate(struct Curl_one_easy *easy, CURLMstate state)
{ {
#ifdef CURLDEBUG #ifdef CURLDEBUG
long index = -5000; long connectindex = -5000;
#endif #endif
CURLMstate oldstate = easy->state; CURLMstate oldstate = easy->state;
@ -231,12 +231,12 @@ static void multistate(struct Curl_one_easy *easy, CURLMstate state)
#ifdef CURLDEBUG #ifdef CURLDEBUG
if(easy->state > CURLM_STATE_CONNECT && if(easy->state > CURLM_STATE_CONNECT &&
easy->state < CURLM_STATE_COMPLETED) easy->state < CURLM_STATE_COMPLETED)
index = easy->easy_conn->connectindex; connectindex = easy->easy_conn->connectindex;
infof(easy->easy_handle, infof(easy->easy_handle,
"STATE: %s => %s handle %p; (connection #%ld) \n", "STATE: %s => %s handle %p; (connection #%ld) \n",
statename[oldstate], statename[easy->state], statename[oldstate], statename[easy->state],
(char *)easy, index); (char *)easy, connectindex);
#endif #endif
if(state == CURLM_STATE_COMPLETED) if(state == CURLM_STATE_COMPLETED)
/* changing to COMPLETED means there's one less easy handle 'alive' */ /* 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)); new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist));
if (new_item) { if (new_item) {
char *dup = strdup(data); char *dupdata = strdup(data);
if(dup) { if(dupdata) {
new_item->next = NULL; new_item->next = NULL;
new_item->data = dup; new_item->data = dupdata;
} }
else { else {
free(new_item); 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. 'newroot' will be made to point to NULL.
*/ */
int Curl_splayremovebyaddr(struct Curl_tree *t, int Curl_splayremovebyaddr(struct Curl_tree *t,
struct Curl_tree *remove, struct Curl_tree *removenode,
struct Curl_tree **newroot) struct Curl_tree **newroot)
{ {
struct Curl_tree *x; struct Curl_tree *x;
if (!t || !remove) if (!t || !removenode)
return 1; 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 /* 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 and thus we can unlink it easily. The 'smaller' link of a subnode
links to the parent node. */ links to the parent node. */
if (remove->smaller == NULL) if (removenode->smaller == NULL)
return 3; return 3;
remove->smaller->same = remove->same; removenode->smaller->same = removenode->same;
if(remove->same) if(removenode->same)
remove->same->smaller = remove->smaller; removenode->same->smaller = removenode->smaller;
/* Ensures that double-remove gets caught. */ /* Ensures that double-remove gets caught. */
remove->smaller = NULL; removenode->smaller = NULL;
/* voila, we're done! */ /* voila, we're done! */
*newroot = t; /* return the same root */ *newroot = t; /* return the same root */
return 0; 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 /* 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 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 We cannot just compare the keys here as a double remove in quick
succession of a node with key != KEY_NOTUSED && same != NULL succession of a node with key != KEY_NOTUSED && same != NULL
could return the same key but a different node. */ could return the same key but a different node. */
if(t != remove) if(t != removenode)
return 2; return 2;
/* Check if there is a list with identical sizes, as then we're trying to /* 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) if (t->smaller == NULL)
x = t->larger; x = t->larger;
else { else {
x = Curl_splay(remove->key, t->smaller); x = Curl_splay(removenode->key, t->smaller);
x->larger = t->larger; 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 *Curl_splaygetbest(int key, struct Curl_tree *t,
struct Curl_tree **removed); struct Curl_tree **removed);
int Curl_splayremovebyaddr(struct Curl_tree *t, int Curl_splayremovebyaddr(struct Curl_tree *t,
struct Curl_tree *remove, struct Curl_tree *removenode,
struct Curl_tree **newroot); struct Curl_tree **newroot);
#ifdef CURLDEBUG #ifdef CURLDEBUG

View File

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

View File

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

View File

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

View File

@ -31,14 +31,14 @@ struct userdata {
}; };
/* lock callback */ /* 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 ) void *useptr )
{ {
const char *what; const char *what;
struct userdata *user = (struct userdata *)useptr; struct userdata *user = (struct userdata *)useptr;
(void)handle; (void)handle;
(void)access; (void)laccess;
switch ( data ) { switch ( data ) {
case CURL_LOCK_DATA_SHARE: 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, static curl_socket_t sockdaemon(curl_socket_t sock,
unsigned short *port) unsigned short *listenport)
{ {
/* passive daemon style */ /* passive daemon style */
struct sockaddr_in me; struct sockaddr_in me;
@ -441,7 +441,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
#endif #endif
me.sin_family = AF_INET; me.sin_family = AF_INET;
me.sin_addr.s_addr = INADDR_ANY; 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)); rc = bind(sock, (struct sockaddr *) &me, sizeof(me));
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
} }
@ -449,7 +449,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
memset(&me6, 0, sizeof(struct sockaddr_in6)); memset(&me6, 0, sizeof(struct sockaddr_in6));
me6.sin6_family = AF_INET6; me6.sin6_family = AF_INET6;
me6.sin6_addr = in6addr_any; me6.sin6_addr = in6addr_any;
me6.sin6_port = htons(*port); me6.sin6_port = htons(*listenport);
rc = bind(sock, (struct sockaddr *) &me6, sizeof(me6)); rc = bind(sock, (struct sockaddr *) &me6, sizeof(me6));
} }
#endif /* ENABLE_IPV6 */ #endif /* ENABLE_IPV6 */
@ -459,7 +459,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
return CURL_SOCKET_BAD; return CURL_SOCKET_BAD;
} }
if(!*port) { if(!*listenport) {
/* The system picked a port number, now figure out which port we actually /* The system picked a port number, now figure out which port we actually
got */ got */
/* we succeeded to bind */ /* we succeeded to bind */
@ -471,7 +471,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
logmsg("getsockname() failed with error: %d", SOCKERRNO); logmsg("getsockname() failed with error: %d", SOCKERRNO);
return CURL_SOCKET_BAD; return CURL_SOCKET_BAD;
} }
*port = ntohs(add.sin_port); *listenport = ntohs(add.sin_port);
} }
/* start accepting connections */ /* start accepting connections */
@ -485,13 +485,13 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
return sock; return sock;
} }
static curl_socket_t mksock(bool use_ipv6) static curl_socket_t mksock(bool ipv6)
{ {
curl_socket_t sock; curl_socket_t sock;
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
if(!use_ipv6) if(!ipv6)
#else #else
(void)use_ipv6; (void)ipv6;
#endif #endif
sock = socket(AF_INET, SOCK_STREAM, 0); sock = socket(AF_INET, SOCK_STREAM, 0);
#ifdef ENABLE_IPV6 #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) static ssize_t write_behind(struct testcase *test, int convert)
{ {
char *buf; char *writebuf;
int count; int count;
int ct; int ct;
char *p; char *p;
@ -312,15 +312,15 @@ static ssize_t write_behind(struct testcase *test, int convert)
b->counter = BF_FREE; /* reset flag */ b->counter = BF_FREE; /* reset flag */
dp = (struct tftphdr *)b->buf; dp = (struct tftphdr *)b->buf;
nextone = !nextone; /* incr for next time */ nextone = !nextone; /* incr for next time */
buf = dp->th_data; writebuf = dp->th_data;
if (count <= 0) if (count <= 0)
return -1; /* nak logic? */ return -1; /* nak logic? */
if (convert == 0) if (convert == 0)
return write(test->ofile, buf, count); return write(test->ofile, writebuf, count);
p = buf; p = writebuf;
ct = count; ct = count;
while (ct--) { /* loop over the buffer */ while (ct--) { /* loop over the buffer */
c = *p++; /* pick up a character */ c = *p++; /* pick up a character */
@ -363,8 +363,8 @@ static int synchnet(curl_socket_t f /* socket to flush */)
#endif #endif
int j = 0; int j = 0;
char rbuf[PKTSIZE]; char rbuf[PKTSIZE];
struct sockaddr_in from; struct sockaddr_in fromaddr;
socklen_t fromlen; socklen_t fromaddrlen;
while (1) { while (1) {
#if defined(HAVE_IOCTLSOCKET) #if defined(HAVE_IOCTLSOCKET)
@ -374,9 +374,9 @@ static int synchnet(curl_socket_t f /* socket to flush */)
#endif #endif
if (i) { if (i) {
j++; j++;
fromlen = sizeof from; fromaddrlen = sizeof fromaddr;
(void) recvfrom(f, rbuf, sizeof (rbuf), 0, (void) recvfrom(f, rbuf, sizeof (rbuf), 0,
(struct sockaddr *)&from, &fromlen); (struct sockaddr *)&fromaddr, &fromaddrlen);
} }
else else
break; break;