From: Remi Gacogne Date: Mon, 16 Jan 2017 16:45:34 +0000 (+0100) Subject: rec: Fix shadowed variables X-Git-Tag: rec-4.1.0-alpha1~306^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd07976412d9b2b35db7179ceb590e542aff9eef;p=pdns rec: Fix shadowed variables No real issue here, but I'd like to be able `-Wshadow` to prevent future mishaps at some point. --- diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index 0b410eb43..3cf483549 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -426,7 +426,7 @@ extern BackendMakerClass &BackendMakers(); class DBException : public PDNSException { public: - DBException(const string &reason) : PDNSException(reason){} + DBException(const string &reason_) : PDNSException(reason_){} }; /** helper function for both DNSPacket and addSOARecord() - converts a line into a struct, for easier parsing */ diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index 00b074919..89f5ee911 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -231,15 +231,15 @@ inline DNSName operator+(const DNSName& lhs, const DNSName& rhs) anything part of that domain will return 'true' in check */ struct SuffixMatchNode { - SuffixMatchNode(const std::string& name_="", bool endNode_=false) : name(name_), endNode(endNode_) + SuffixMatchNode(const std::string& name_="", bool endNode_=false) : d_name(name_), endNode(endNode_) {} - std::string name; + std::string d_name; std::string d_human; mutable std::set children; mutable bool endNode; bool operator<(const SuffixMatchNode& rhs) const { - return strcasecmp(name.c_str(), rhs.name.c_str()) < 0; + return strcasecmp(d_name.c_str(), rhs.d_name.c_str()) < 0; } void add(const DNSName& dnsname) diff --git a/pdns/lua-recursor4.cc b/pdns/lua-recursor4.cc index 13b5a7f70..850a97d17 100644 --- a/pdns/lua-recursor4.cc +++ b/pdns/lua-recursor4.cc @@ -328,8 +328,8 @@ RecursorLua4::RecursorLua4(const std::string& fname) cas.insert(ComboAddress(*s)); } else if(auto v = boost::get > >(&in)) { - for(const auto& s : *v) - cas.insert(ComboAddress(s.second)); + for(const auto&entry : *v) + cas.insert(ComboAddress(entry.second)); } else { cas.insert(boost::get(in)); @@ -440,8 +440,8 @@ RecursorLua4::RecursorLua4(const std::string& fname) if(auto rec = std::dynamic_pointer_cast(dr.d_content)) ret=rec->getCA(53); - else if(auto rec = std::dynamic_pointer_cast(dr.d_content)) - ret=rec->getCA(53); + else if(auto aaaarec = std::dynamic_pointer_cast(dr.d_content)) + ret=aaaarec->getCA(53); return ret; }); @@ -487,8 +487,8 @@ RecursorLua4::RecursorLua4(const std::string& fname) smn.add(DNSName(*s)); } else if(auto v = boost::get > >(&in)) { - for(const auto& s : *v) - smn.add(DNSName(s.second)); + for(const auto& entry : *v) + smn.add(DNSName(entry.second)); } else { smn.add(boost::get(in)); @@ -683,12 +683,12 @@ loop:; } else if(dq.followupFunction=="udpQueryResponse") { dq.udpAnswer = GenUDPQueryResponse(dq.udpQueryDest, dq.udpQuery); - auto func = d_lw->readVariable>(dq.udpCallback).get_value_or(0); - if(!func) { + auto cbFunc = d_lw->readVariable>(dq.udpCallback).get_value_or(0); + if(!cbFunc) { theL()<(bitmap[n++]); - unsigned int len=static_cast(bitmap[n++]); + unsigned int blen=static_cast(bitmap[n++]); // end if zero padding and ensure packet length - if(window == 0&&len == 0) break; - if(n+len>bitmap.size()) + if(window == 0 && blen == 0) break; + if(n + blen > bitmap.size()) throw MOADNSException("NSEC record with bitmap length > packet length"); - for(unsigned int k=0; k < len; k++) { + for(unsigned int k=0; k < blen; k++) { uint8_t val=bitmap[n++]; - for(int bit = 0; bit < 8 ; ++bit , val>>=1) - if(val & 1) { + for(int bit = 0; bit < 8 ; ++bit , val>>=1) + if(val & 1) { ret->d_set.insert((7-bit) + 8*(k) + 256*window); } } diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 16c114667..7e669692e 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1161,15 +1161,15 @@ void startDoResolve(void *p) iov[0].iov_base=(void*)buf; iov[0].iov_len=2; iov[1].iov_base=(void*)&*packet.begin(); iov[1].iov_len = packet.size(); - int ret=Utility::writev(dc->d_socket, iov, 2); + int wret=Utility::writev(dc->d_socket, iov, 2); bool hadError=true; - if(ret == 0) + if(wret == 0) L<getRemote()<getRemote()<<": "<< strerror(errno) <getRemote()<<" for "<d_mdp.d_qname<<" (size="<< (2 + packet.size()) <<", sent "<getRemote()<<" for "<d_mdp.d_qname<<" (size="<< (2 + packet.size()) <<", sent "<= sizeof(struct dnsheader)) { - struct dnsheader dh; - memcpy(&dh, response.c_str(), sizeof(dh)); - updateResponseStats(dh.rcode, fromaddr, response.length(), 0, 0); + struct dnsheader tmpdh; + memcpy(&tmpdh, response.c_str(), sizeof(tmpdh)); + updateResponseStats(tmpdh.rcode, fromaddr, response.length(), 0, 0); } g_stats.avgLatencyUsec=(1-1.0/g_latencyStatSize)*g_stats.avgLatencyUsec + 0.0; // we assume 0 usec return 0; @@ -1887,7 +1887,6 @@ void makeUDPServerSockets() #ifdef SO_REUSEPORT if(::arg().mustDo("reuseport")) { - int one=1; if(setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) < 0) throw PDNSException("SO_REUSEPORT: "+stringerror()); } diff --git a/pdns/rec-lua-conf.cc b/pdns/rec-lua-conf.cc index fe7d5570d..5b7052a5e 100644 --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@ -89,7 +89,7 @@ void loadRecursorLuaConfig(const std::string& fname, bool checkOnly) }; Lua.writeVariable("Policy", pmap); - Lua.writeFunction("rpzFile", [&lci](const string& fname, const boost::optional>>& options) { + Lua.writeFunction("rpzFile", [&lci](const string& filename, const boost::optional>>& options) { try { boost::optional defpol; std::string polName("rpzFile"); @@ -118,13 +118,13 @@ void loadRecursorLuaConfig(const std::string& fname, bool checkOnly) } } const size_t zoneIdx = lci.dfe.size(); - theL()< > >(e.second); - for(const auto& e : v) - lci.sortlist.addEntry(formask, Netmask(e.second), order); + for(const auto& entry : v) + lci.sortlist.addEntry(formask, Netmask(entry.second), order); } ++order; } @@ -325,13 +325,13 @@ void loadRecursorLuaConfig(const std::string& fname, bool checkOnly) theL()<(boost::bind(pleaseWipePacketCache, who, true)); + broadcastAccFunction(boost::bind(pleaseWipePacketCache, entry, true)); if (!first) { first = false; removed += ","; } - removed += " " + who.toStringRootDot(); + removed += " " + entry.toStringRootDot(); } return "Removed Negative Trust Anchors for " + removed + "\n"; } @@ -547,17 +547,17 @@ string doClearTA(T begin, T end) string removed(""); bool first(true); - for (auto const &who : toRemove) { - L<(boost::bind(pleaseWipePacketCache, who, true)); + broadcastAccFunction(boost::bind(pleaseWipePacketCache, entry, true)); if (!first) { first = false; removed += ","; } - removed += " " + who.toStringRootDot(); + removed += " " + entry.toStringRootDot(); } return "Removed Trust Anchor(s) for" + removed + "\n"; } diff --git a/pdns/resolver.hh b/pdns/resolver.hh index 196831b4b..e6c6e7ae5 100644 --- a/pdns/resolver.hh +++ b/pdns/resolver.hh @@ -46,7 +46,7 @@ class ResolverException : public PDNSException { public: - ResolverException(const string &reason) : PDNSException(reason){} + ResolverException(const string &reason_) : PDNSException(reason_){} }; // make an IPv4 or IPv6 query socket diff --git a/pdns/rpzloader.cc b/pdns/rpzloader.cc index e5f4eef72..8078b8759 100644 --- a/pdns/rpzloader.cc +++ b/pdns/rpzloader.cc @@ -75,33 +75,33 @@ void RPZRecordToPolicy(const DNSRecord& dr, DNSFilterEngine& target, bool addOrR if (!crc) { return; } - auto target=crc->getTarget(); + auto crcTarget=crc->getTarget(); if(defpol) { pol=*defpol; } - else if(target.isRoot()) { + else if(crcTarget.isRoot()) { // cerr<<"Wants NXDOMAIN for "< SyncRes::getAddrs(const DNSName &qname, unsigned int depth, if(i->d_type == QType::A || i->d_type == QType::AAAA) { if(auto rec = std::dynamic_pointer_cast(i->d_content)) ret.push_back(rec->getCA(53)); - else if(auto rec = std::dynamic_pointer_cast(i->d_content)) - ret.push_back(rec->getCA(53)); + else if(auto aaaarec = std::dynamic_pointer_cast(i->d_content)) + ret.push_back(aaaarec->getCA(53)); done=true; } } @@ -719,14 +719,14 @@ bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector ret.push_back(dr); for(const auto& signature : signatures) { - DNSRecord dr; - dr.d_type=QType::RRSIG; - dr.d_name=qname; - dr.d_ttl=j->d_ttl - d_now.tv_sec; - dr.d_content=signature; - dr.d_place=DNSResourceRecord::ANSWER; - dr.d_class=1; - ret.push_back(dr); + DNSRecord sigdr; + sigdr.d_type=QType::RRSIG; + sigdr.d_name=qname; + sigdr.d_ttl=j->d_ttl - d_now.tv_sec; + sigdr.d_content=signature; + sigdr.d_place=DNSResourceRecord::ANSWER; + sigdr.d_class=1; + ret.push_back(sigdr); } if(!(qtype==QType(QType::CNAME))) { // perhaps they really wanted a CNAME! diff --git a/pdns/webserver.cc b/pdns/webserver.cc index 6a092373b..2c22bb49c 100644 --- a/pdns/webserver.cc +++ b/pdns/webserver.cc @@ -90,16 +90,16 @@ void HttpResponse::setBody(const json11::Json& document) document.dump(this->body); } -void HttpResponse::setErrorResult(const std::string& message, const int status) +void HttpResponse::setErrorResult(const std::string& message, const int status_) { setBody(json11::Json::object { { "error", message } }); - this->status = status; + this->status = status_; } -void HttpResponse::setSuccessResult(const std::string& message, const int status) +void HttpResponse::setSuccessResult(const std::string& message, const int status_) { setBody(json11::Json::object { { "result", message } }); - this->status = status; + this->status = status_; } static void bareHandlerWrapper(WebServer::HandlerFunction handler, YaHTTP::Request* req, YaHTTP::Response* resp) diff --git a/pdns/ws-api.cc b/pdns/ws-api.cc index bb2ee8e20..75498a0de 100644 --- a/pdns/ws-api.cc +++ b/pdns/ws-api.cc @@ -177,8 +177,8 @@ static Json logGrep(const string& q, const string& fname, const string& prefix) } Json::array items; - for(const string& line : lines) { - items.push_back(line); + for(const string& iline : lines) { + items.push_back(iline); } return items; }