From: Francesco Chemolli Date: Wed, 18 Nov 2009 12:37:56 +0000 (+0100) Subject: Fixed some cases of variable shadowing X-Git-Tag: SQUID_3_2_0_1~560 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e053c141e955538f4b2a06f31ead42b66a3f3abd;p=thirdparty%2Fsquid.git Fixed some cases of variable shadowing --- diff --git a/helpers/basic_auth/squid_radius_auth/squid_rad_auth.c b/helpers/basic_auth/squid_radius_auth/squid_rad_auth.c index 02bfd3014c..67e5cefb1d 100644 --- a/helpers/basic_auth/squid_radius_auth/squid_rad_auth.c +++ b/helpers/basic_auth/squid_radius_auth/squid_rad_auth.c @@ -288,7 +288,7 @@ urldecode(char *dst, const char *src, int size) } static int -authenticate(int sockfd, const char *username, const char *passwd) +authenticate(int socket_fd, const char *username, const char *passwd) { AUTH_HDR *auth; u_short total_length; @@ -414,7 +414,7 @@ authenticate(int sockfd, const char *username, const char *passwd) * Send the request we've built. */ gettimeofday(&sent, NULL); - send(sockfd, (char *) auth, total_length, 0); + send(socket_fd, (char *) auth, total_length, 0); while ((time_spent = time_since(&sent)) < 1000000) { struct timeval tv; int rc, len; @@ -426,11 +426,11 @@ authenticate(int sockfd, const char *username, const char *passwd) tv.tv_usec = 1000000 - time_spent; } FD_ZERO(&readfds); - FD_SET(sockfd, &readfds); - if (select(sockfd + 1, &readfds, NULL, NULL, &tv) == 0) /* Select timeout */ + FD_SET(socket_fd, &readfds); + if (select(socket_fd + 1, &readfds, NULL, NULL, &tv) == 0) /* Select timeout */ break; salen = sizeof(saremote); - len = recvfrom(sockfd, recv_buffer, sizeof(i_recv_buffer), + len = recvfrom(socket_fd, recv_buffer, sizeof(i_recv_buffer), 0, (struct sockaddr *) &saremote, &salen); if (len < 0) diff --git a/helpers/digest_auth/password/text_backend.c b/helpers/digest_auth/password/text_backend.c index 384045670d..0662555c72 100644 --- a/helpers/digest_auth/password/text_backend.c +++ b/helpers/digest_auth/password/text_backend.c @@ -53,7 +53,7 @@ my_free(void *p) } static void -read_passwd_file(const char *passwdfile, int ha1mode) +read_passwd_file(const char *passwdfile, int isHa1Mode) { FILE *f; char buf[8192]; @@ -88,7 +88,7 @@ read_passwd_file(const char *passwdfile, int ha1mode) if (strncmp(passwd, "{HHA1}", 6) == 0) { ha1 = passwd + 6; passwd = NULL; - } else if (ha1mode) { + } else if (isHa1Mode) { ha1 = passwd; passwd = NULL; } diff --git a/helpers/external_acl/session/squid_session.c b/helpers/external_acl/session/squid_session.c index 8b5b80618b..f92c0c98c3 100644 --- a/helpers/external_acl/session/squid_session.c +++ b/helpers/external_acl/session/squid_session.c @@ -149,10 +149,10 @@ int main(int argc, char **argv) init_db(); while (fgets(request, sizeof(request), stdin)) { - const char *index, *detail; + const char *user_key, *detail; char *lastdetail; int action = 0; - index = strtok(request, " \n"); + user_key = strtok(request, " \n"); detail = strtok(NULL, "\n"); lastdetail = strrchr(detail, ' '); if (lastdetail) { @@ -166,18 +166,18 @@ int main(int argc, char **argv) } if (action == -1) { session_logout(detail); - printf("%s OK message=\"Bye\"\n", index); + printf("%s OK message=\"Bye\"\n", user_key); } else if (action == 1) { session_login(detail); - printf("%s OK message=\"Welcome\"\n", index); + printf("%s OK message=\"Welcome\"\n", user_key); } else if (session_active(detail)) { session_login(detail); - printf("%s OK\n", index); + printf("%s OK\n", user_key); } else if (default_action == 1) { session_login(detail); - printf("%s ERR message=\"Welcome\"\n", index); + printf("%s ERR message=\"Welcome\"\n", user_key); } else { - printf("%s ERR message=\"No session available\"\n", index); + printf("%s ERR message=\"No session available\"\n", user_key); } } shutdown_db(); diff --git a/src/SwapDir.cc b/src/SwapDir.cc index d5d75ca1b4..581e4ba74d 100644 --- a/src/SwapDir.cc +++ b/src/SwapDir.cc @@ -165,7 +165,7 @@ SwapDir::getOptionTree() const } void -SwapDir::parseOptions(int reconfiguring) +SwapDir::parseOptions(int isaReconfig) { unsigned int old_read_only = flags.read_only; char *name, *value; @@ -181,7 +181,7 @@ SwapDir::parseOptions(int reconfiguring) debugs(3,2, "SwapDir::parseOptions: parsing store option '" << name << "'='" << (value ? value : "") << "'"); if (newOption) - if (!newOption->parse(name, value, reconfiguring)) + if (!newOption->parse(name, value, isaReconfig)) self_destruct(); } @@ -193,7 +193,7 @@ SwapDir::parseOptions(int reconfiguring) * parsing... */ - if (reconfiguring) { + if (isaReconfig) { if (old_read_only != flags.read_only) { debugs(3, 1, "Cache dir '" << path << "' now " << (flags.read_only ? "No-Store" : "Read-Write")); } @@ -212,7 +212,7 @@ SwapDir::dumpOptions(StoreEntry * entry) const } bool -SwapDir::optionReadOnlyParse(char const *option, const char *value, int reconfiguring) +SwapDir::optionReadOnlyParse(char const *option, const char *value, int isaReconfig) { if (strcmp(option, "no-store") != 0 && strcmp(option, "read-only") != 0) return false; @@ -237,7 +237,7 @@ SwapDir::optionReadOnlyDump(StoreEntry * e) const } bool -SwapDir::optionMaxSizeParse(char const *option, const char *value, int reconfiguring) +SwapDir::optionMaxSizeParse(char const *option, const char *value, int isaReconfig) { if (strcmp(option, "max-size") != 0) return false; @@ -247,7 +247,7 @@ SwapDir::optionMaxSizeParse(char const *option, const char *value, int reconfigu int64_t size = strtoll(value, NULL, 10); - if (reconfiguring && max_objsize != size) + if (isaReconfig && max_objsize != size) debugs(3, 1, "Cache dir '" << path << "' max object size now " << size); max_objsize = size; @@ -276,7 +276,7 @@ SwapDir::get void SwapDir::get -(String const key, STOREGETCLIENT callback, void *cbdata) +(String const key, STOREGETCLIENT aCallback, void *aCallbackData) { fatal("not implemented"); } diff --git a/src/client_side.cc b/src/client_side.cc index 661abefcf9..45a13d09c9 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1669,23 +1669,23 @@ ClientSocketContext::initiateClose(const char *reason) } void -ClientSocketContext::writeComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag) +ClientSocketContext::writeComplete(int aFileDescriptor, char *bufnotused, size_t size, comm_err_t errflag) { StoreEntry *entry = http->storeEntry(); http->out.size += size; - assert(fd > -1); - debugs(33, 5, "clientWriteComplete: FD " << fd << ", sz " << size << + assert(aFileDescriptor > -1); + debugs(33, 5, "clientWriteComplete: FD " << aFileDescriptor << ", sz " << size << ", err " << errflag << ", off " << http->out.size << ", len " << entry ? entry->objectLen() : 0); clientUpdateSocketStats(http->logType, size); - assert (this->fd() == fd); + assert (this->fd() == aFileDescriptor); /* Bail out quickly on COMM_ERR_CLOSING - close handlers will tidy up */ if (errflag == COMM_ERR_CLOSING) return; - if (errflag || clientHttpRequestStatus(fd, http)) { + if (errflag || clientHttpRequestStatus(aFileDescriptor, http)) { initiateClose("failure or true request status"); /* Do we leak here ? */ return; @@ -1698,7 +1698,7 @@ ClientSocketContext::writeComplete(int fd, char *bufnotused, size_t size, comm_e break; case STREAM_COMPLETE: - debugs(33, 5, "clientWriteComplete: FD " << fd << " Keeping Alive"); + debugs(33, 5, "clientWriteComplete: FD " << aFileDescriptor << " Keeping Alive"); keepaliveNextRequest(); return; diff --git a/src/errorpage.cc b/src/errorpage.cc index f0424f2b04..a3382e97d1 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -554,7 +554,7 @@ ErrorState::Dump(MemBuf * mb) str.Printf("HTTP Request:\r\n"); if (NULL != request) { - Packer p; + Packer pck; String urlpath_or_slash; if (request->urlpath.size() != 0) @@ -566,9 +566,9 @@ ErrorState::Dump(MemBuf * mb) RequestMethodStr(request->method), SQUIDSTRINGPRINT(urlpath_or_slash), request->http_ver.major, request->http_ver.minor); - packerToMemInit(&p, &str); - request->header.packInto(&p); - packerClean(&p); + packerToMemInit(&pck, &str); + request->header.packInto(&pck); + packerClean(&pck); } else if (request_hdrs) { p = request_hdrs; } else { diff --git a/src/event.cc b/src/event.cc index f07437e986..6dc15dba40 100644 --- a/src/event.cc +++ b/src/event.cc @@ -108,10 +108,10 @@ EventDialer::print(std::ostream &os) const } -ev_entry::ev_entry(char const * name, EVH * func, void * arg, double when, - int weight, bool cbdata) : name(name), func(func), - arg(cbdata ? cbdataReference(arg) : arg), when(when), weight(weight), - cbdata(cbdata) +ev_entry::ev_entry(char const * aName, EVH * aFunction, void * aArgument, double when, + int weight, bool haveArgument) : name(aName), func(aFunction), + arg(haveArgument ? cbdataReference(aArgument) : aArgument), when(when), weight(weight), + cbdata(haveArgument) { } diff --git a/src/ftp.cc b/src/ftp.cc index c8a48e4ca9..e8e05eb8c7 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -3786,10 +3786,10 @@ FtpStateData::printfReplyBody(const char *fmt, ...) * which should be sent to either StoreEntry, or to ICAP... */ void -FtpStateData::writeReplyBody(const char *data, size_t len) +FtpStateData::writeReplyBody(const char *dataToWrite, size_t dataLength) { - debugs(9, 5, HERE << "writing " << len << " bytes to the reply"); - addVirginReplyBody(data, len); + debugs(9, 5, HERE << "writing " << dataLength << " bytes to the reply"); + addVirginReplyBody(dataToWrite, dataLength); } /** diff --git a/src/http.cc b/src/http.cc index 749a070424..263444a377 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1224,22 +1224,22 @@ HttpStateData::decodeAndWriteReplyBody() { const char *data = NULL; int len; - bool status = false; + bool wasThereAnException = false; assert(flags.chunked); assert(httpChunkDecoder); SQUID_ENTER_THROWING_CODE(); MemBuf decodedData; decodedData.init(); - const bool done = httpChunkDecoder->parse(readBuf,&decodedData); + const bool doneParsing = httpChunkDecoder->parse(readBuf,&decodedData); len = decodedData.contentSize(); data=decodedData.content(); addVirginReplyBody(data, len); - if (done) { + if (doneParsing) { lastChunk = 1; flags.do_next_read = 0; } - SQUID_EXIT_THROWING_CODE(status); - return status; + SQUID_EXIT_THROWING_CODE(wasThereAnException); + return wasThereAnException; } /** @@ -1911,28 +1911,28 @@ HttpStateData::decideIfWeDoRanges (HttpRequest * orig_request) /* build request prefix and append it to a given MemBuf; * return the length of the prefix */ mb_size_t -HttpStateData::buildRequestPrefix(HttpRequest * request, - HttpRequest * orig_request, - StoreEntry * entry, +HttpStateData::buildRequestPrefix(HttpRequest * aRequest, + HttpRequest * original_request, + StoreEntry * sentry, MemBuf * mb, - http_state_flags flags) + http_state_flags stateFlags) { const int offset = mb->size; HttpVersion httpver(1, 0); mb->Printf("%s %s HTTP/%d.%d\r\n", - RequestMethodStr(request->method), - request->urlpath.size() ? request->urlpath.termedBuf() : "/", + RequestMethodStr(aRequest->method), + aRequest->urlpath.size() ? aRequest->urlpath.termedBuf() : "/", httpver.major,httpver.minor); /* build and pack headers */ { HttpHeader hdr(hoRequest); Packer p; - httpBuildRequestHeader(request, orig_request, entry, &hdr, flags); + httpBuildRequestHeader(aRequest, original_request, sentry, &hdr, stateFlags); - if (request->flags.pinned && request->flags.connection_auth) - request->flags.auth_sent = 1; + if (aRequest->flags.pinned && aRequest->flags.connection_auth) + aRequest->flags.auth_sent = 1; else if (hdr.has(HDR_AUTHORIZATION)) - request->flags.auth_sent = 1; + aRequest->flags.auth_sent = 1; packerToMemInit(&p, mb); hdr.packInto(&p); diff --git a/src/main.cc b/src/main.cc index 554e4e4880..5ef34a034c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -167,7 +167,7 @@ class SignalEngine: public AsyncEngine { public: - SignalEngine(EventLoop &loop) : loop(loop) {} + SignalEngine(EventLoop &evtLoop) : loop(evtLoop) {} virtual int checkEvents(int timeout); private: diff --git a/src/stat.cc b/src/stat.cc index cb67d2cd27..693032fea3 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1094,12 +1094,12 @@ statAvgTick(void *notused) if ((NCountHist % COUNT_INTERVAL) == 0) { /* we have an hours worth of readings. store previous hour */ - StatCounters *t = &CountHourHist[0]; - StatCounters *p = &CountHourHist[1]; - StatCounters *c = &CountHist[N_COUNT_HIST - 1]; + StatCounters *t2 = &CountHourHist[0]; + StatCounters *p2 = &CountHourHist[1]; + StatCounters *c2 = &CountHist[N_COUNT_HIST - 1]; statCountersClean(CountHourHist + N_COUNT_HOUR_HIST - 1); - xmemmove(p, t, (N_COUNT_HOUR_HIST - 1) * sizeof(StatCounters)); - statCountersCopy(t, c); + xmemmove(p2, t2, (N_COUNT_HOUR_HIST - 1) * sizeof(StatCounters)); + statCountersCopy(t2, c2); NCountHourHist++; } diff --git a/src/store_dir.cc b/src/store_dir.cc index 55368f551a..18d641ed56 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -705,7 +705,7 @@ StoreController::get void StoreController::get -(String const key, STOREGETCLIENT callback, void *cbdata) +(String const key, STOREGETCLIENT aCallback, void *aCallbackData) { fatal("not implemented"); } @@ -782,7 +782,7 @@ StoreHashIndex::get void StoreHashIndex::get -(String const key, STOREGETCLIENT callback, void *cbdata) +(String const key, STOREGETCLIENT aCallback, void *aCallbackData) { fatal("not implemented"); } diff --git a/src/unlinkd.cc b/src/unlinkd.cc index 1486450ee0..f3b16aec26 100644 --- a/src/unlinkd.cc +++ b/src/unlinkd.cc @@ -53,7 +53,7 @@ unlinkdUnlink(const char *path) { char buf[MAXPATHLEN]; int l; - int x; + int bytes_written; static int queuelen = 0; if (unlinkd_wfd < 0) { @@ -98,15 +98,15 @@ unlinkdUnlink(const char *path) * decrement the queue size by the number of newlines read. */ if (queuelen > 0) { - int x; + int bytes_read; int i; char rbuf[512]; - x = read(unlinkd_rfd, rbuf, 511); + bytes_read = read(unlinkd_rfd, rbuf, 511); - if (x > 0) { - rbuf[x] = '\0'; + if (bytes_read > 0) { + rbuf[bytes_read] = '\0'; - for (i = 0; i < x; i++) + for (i = 0; i < bytes_read; i++) if ('\n' == rbuf[i]) queuelen--; @@ -118,14 +118,14 @@ unlinkdUnlink(const char *path) assert(l < MAXPATHLEN); xstrncpy(buf, path, MAXPATHLEN); buf[l++] = '\n'; - x = write(unlinkd_wfd, buf, l); + bytes_written = write(unlinkd_wfd, buf, l); - if (x < 0) { + if (bytes_written < 0) { debugs(2, 1, "unlinkdUnlink: write FD " << unlinkd_wfd << " failed: " << xstrerror()); safeunlink(path, 0); return; - } else if (x != l) { - debugs(2, 1, "unlinkdUnlink: FD " << unlinkd_wfd << " only wrote " << x << " of " << l << " bytes"); + } else if (bytes_written != l) { + debugs(2, 1, "unlinkdUnlink: FD " << unlinkd_wfd << " only wrote " << bytes_written << " of " << l << " bytes"); safeunlink(path, 0); return; } diff --git a/src/whois.cc b/src/whois.cc index 34fcf7f076..ff7f52c25a 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -49,8 +49,8 @@ class WhoisState public: ~WhoisState(); - void readReply (int fd, char *buf, size_t len, comm_err_t flag, int xerrno); - void setReplyToOK(StoreEntry *entry); + void readReply (int fd, char *aBuffer, size_t aBufferLength, comm_err_t flag, int xerrno); + void setReplyToOK(StoreEntry *sentry); StoreEntry *entry; HttpRequest *request; FwdState::Pointer fwd; @@ -124,17 +124,17 @@ whoisReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void } void -WhoisState::setReplyToOK(StoreEntry *entry) +WhoisState::setReplyToOK(StoreEntry *sentry) { HttpReply *reply = new HttpReply; - entry->buffer(); + sentry->buffer(); HttpVersion version(1, 0); reply->setHeaders(version, HTTP_OK, "Gatewaying", "text/plain", -1, -1, -2); - entry->replaceHttpReply(reply); + sentry->replaceHttpReply(reply); } void -WhoisState::readReply (int fd, char *buf, size_t len, comm_err_t flag, int xerrno) +WhoisState::readReply (int fd, char *aBuffer, size_t aBufferLength, comm_err_t flag, int xerrno) { int do_next_read = 0; @@ -144,27 +144,27 @@ WhoisState::readReply (int fd, char *buf, size_t len, comm_err_t flag, int xerrn return; } - buf[len] = '\0'; - debugs(75, 3, "whoisReadReply: FD " << fd << " read " << len << " bytes"); - debugs(75, 5, "{" << buf << "}"); + aBuffer[aBufferLength] = '\0'; + debugs(75, 3, "whoisReadReply: FD " << fd << " read " << aBufferLength << " bytes"); + debugs(75, 5, "{" << aBuffer << "}"); - if (flag == COMM_OK && len > 0) { + if (flag == COMM_OK && aBufferLength > 0) { if (!dataWritten) setReplyToOK(entry); - kb_incr(&statCounter.server.all.kbytes_in, len); + kb_incr(&statCounter.server.all.kbytes_in, aBufferLength); - kb_incr(&statCounter.server.http.kbytes_in, len); + kb_incr(&statCounter.server.http.kbytes_in, aBufferLength); /* No range support, we always grab it all */ dataWritten = true; - entry->append(buf, len); + entry->append(aBuffer, aBufferLength); entry->flush(); do_next_read = 1; - } else if (flag != COMM_OK || len < 0) { + } else if (flag != COMM_OK || aBufferLength < 0) { debugs(50, 2, "whoisReadReply: FD " << fd << ": read failure: " << xstrerror() << "."); if (ignoreErrno(errno)) { @@ -194,7 +194,7 @@ WhoisState::readReply (int fd, char *buf, size_t len, comm_err_t flag, int xerrn } if (do_next_read) - comm_read(fd, buf, BUFSIZ, whoisReadReply, this); + comm_read(fd, aBuffer, BUFSIZ, whoisReadReply, this); } static void diff --git a/tools/squidclient.cc b/tools/squidclient.cc index 3e2f99461b..25325c6f7d 100644 --- a/tools/squidclient.cc +++ b/tools/squidclient.cc @@ -520,13 +520,13 @@ main(int argc, char *argv[]) iaddr.SetPort(port); if (client_comm_connect(conn, iaddr, ping ? &tv1 : NULL) < 0) { - char buf[MAX_IPSTRLEN]; - iaddr.ToURL(buf, MAX_IPSTRLEN); + char hostnameBuf[MAX_IPSTRLEN]; + iaddr.ToURL(hostnameBuf, MAX_IPSTRLEN); if (errno == 0) { - fprintf(stderr, "client: ERROR: Cannot connect to %s: Host unknown.\n", buf); + fprintf(stderr, "client: ERROR: Cannot connect to %s: Host unknown.\n", hostnameBuf); } else { char tbuf[BUFSIZ]; - snprintf(tbuf, BUFSIZ, "client: ERROR: Cannot connect to %s", buf); + snprintf(tbuf, BUFSIZ, "client: ERROR: Cannot connect to %s", hostnameBuf); perror(tbuf); } exit(1);