From fc5c2d48edf9eaffdefbd192f45318c931aa4a84 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 16 Jan 2017 17:45:34 +0100 Subject: [PATCH] rec: Fix shadowed variables No real issue here, but I'd like to be able `-Wshadow` to prevent future mishaps at some point. (cherry picked from commit dd07976412d9b2b35db7179ceb590e542aff9eef) --- pdns/dnsbackend.hh | 2 +- pdns/dnsname.hh | 6 +++--- pdns/lua-recursor4.cc | 20 ++++++++++---------- pdns/lwres.hh | 2 +- pdns/nsecrecords.cc | 12 ++++++------ pdns/pdns_recursor.cc | 17 ++++++++--------- pdns/rec-lua-conf.cc | 26 +++++++++++++------------- pdns/rec_channel_rec.cc | 24 ++++++++++++------------ pdns/resolver.hh | 2 +- pdns/rpzloader.cc | 14 +++++++------- pdns/syncres.cc | 20 ++++++++++---------- pdns/webserver.cc | 8 ++++---- pdns/ws-api.cc | 4 ++-- 13 files changed, 78 insertions(+), 79 deletions(-) diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index 9ae0492e8..0000852fe 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -425,7 +425,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 e9adc82fb..980196276 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -229,15 +229,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& name) diff --git a/pdns/lua-recursor4.cc b/pdns/lua-recursor4.cc index ea0cde2bf..4a9cbde07 100644 --- a/pdns/lua-recursor4.cc +++ b/pdns/lua-recursor4.cc @@ -302,8 +302,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)); @@ -408,8 +408,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; }); @@ -455,8 +455,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)); @@ -648,14 +648,14 @@ 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()<variable; // could still be set to indicate this *name* is variable - if(!res) { + if(!result) { return false; } goto loop; diff --git a/pdns/lwres.hh b/pdns/lwres.hh index 1762ed98a..e04e67f20 100644 --- a/pdns/lwres.hh +++ b/pdns/lwres.hh @@ -51,7 +51,7 @@ int arecvfrom(char *data, size_t len, int flags, const ComboAddress& ip, size_t class LWResException : public PDNSException { public: - LWResException(const string &reason) : PDNSException(reason){} + LWResException(const string &reason_) : PDNSException(reason_){} }; //! LWRes class diff --git a/pdns/nsecrecords.cc b/pdns/nsecrecords.cc index 4796f4d40..dc239509d 100644 --- a/pdns/nsecrecords.cc +++ b/pdns/nsecrecords.cc @@ -97,17 +97,17 @@ NSECRecordContent::DNSRecordContent* NSECRecordContent::make(const DNSRecord &dr for(unsigned int n = 0; n+1 < bitmap.size();) { unsigned int window=static_cast(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 9b2acc8b8..bf2f1522b 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1133,15 +1133,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; @@ -1825,7 +1825,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 2347b18c2..3f1ad6616 100644 --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@ -88,7 +88,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"); @@ -117,13 +117,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; } @@ -317,13 +317,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"; } @@ -529,17 +529,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 548551a0a..fcfa031e8 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 1d2624d9e..bfee4685e 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 18bd62086..40aee59ca 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; } -- 2.40.0