]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Don't shadow variables
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 23 Oct 2017 10:16:52 +0000 (12:16 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 23 Oct 2017 10:16:52 +0000 (12:16 +0200)
26 files changed:
modules/bindbackend/bindbackend2.cc
modules/geoipbackend/geoipbackend.cc
modules/gpgsqlbackend/spgsql.cc
modules/pipebackend/coprocess.cc
modules/remotebackend/pipeconnector.cc
modules/remotebackend/unixconnector.cc
pdns/auth-querycache.hh
pdns/calidns.cc
pdns/dbdnsseckeeper.cc
pdns/dnsdist.cc
pdns/dnsreplay.cc
pdns/lua-auth4.cc
pdns/nproxy.cc
pdns/nsec3dig.cc
pdns/packethandler.cc
pdns/pdns_recursor.cc
pdns/pdnsutil.cc
pdns/pkcs11signers.cc
pdns/recursordist/test-recursorcache_cc.cc
pdns/recursordist/test-syncres_cc.cc
pdns/saxfr.cc
pdns/statnode.cc
pdns/syncres.cc
pdns/tcpreceiver.cc
pdns/test-dnsname_cc.cc
pdns/zoneparser-tng.cc

index ccfec1805e28f100975b48f24e7eba4968168b07..61f4f5e4c78cae0e6b4358094f87158dbb8d398d 100644 (file)
@@ -1309,9 +1309,9 @@ bool Bind2Backend::searchRecords(const string &pattern, int maxResults, vector<D
     for(state_t::const_iterator i = s_state.begin(); i != s_state.end() ; ++i) {
       BB2DomainInfo h;
       safeGetBBDomainInfo(i->d_id, &h);
-      shared_ptr<const recordstorage_t> handle = h.d_records.get();
+      shared_ptr<const recordstorage_t> rhandle = h.d_records.get();
 
-      for(recordstorage_t::const_iterator ri = handle->begin(); result.size() < static_cast<vector<DNSResourceRecord>::size_type>(maxResults) && ri != handle->end(); ri++) {
+      for(recordstorage_t::const_iterator ri = rhandle->begin(); result.size() < static_cast<vector<DNSResourceRecord>::size_type>(maxResults) && ri != rhandle->end(); ri++) {
         DNSName name = ri->qname.empty() ? i->d_name : (ri->qname+i->d_name);
         if (sm.match(name) || sm.match(ri->content)) {
           DNSResourceRecord r;
index 929f5345b37117591e3cefa5671d7f12dcd71b36..b02b475d34a9792a721b8ffc345fd027dd7fc80e 100644 (file)
@@ -91,20 +91,20 @@ void GeoIPBackend::initialize() {
   YAML::Node config;
   vector<GeoIPDomain> tmp_domains;
 
-  string mode = getArg("database-cache");
+  string modeStr = getArg("database-cache");
   int flags;
-  if (mode == "standard") 
+  if (modeStr == "standard")
     flags = GEOIP_STANDARD;
-  else if (mode == "memory")
+  else if (modeStr == "memory")
     flags = GEOIP_MEMORY_CACHE;
-  else if (mode == "index") 
+  else if (modeStr == "index")
     flags = GEOIP_INDEX_CACHE;
 #ifdef HAVE_MMAP
-  else if (mode == "mmap")
+  else if (modeStr == "mmap")
     flags = GEOIP_MMAP_CACHE;
 #endif
   else
-    throw PDNSException("Invalid cache mode " + mode + " for GeoIP backend");
+    throw PDNSException("Invalid cache mode " + modeStr + " for GeoIP backend");
 
   s_geoip_files.clear(); // reset pointers
 
@@ -376,15 +376,15 @@ void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, DNSPacket
   const NetmaskTree<vector<string> >::node_type* node = target->second.lookup(ComboAddress(ip));
   if (node == NULL) return; // no hit, again.
 
-  DNSName format;
+  DNSName sformat;
   gl.netmask = node->first.getBits();
 
   // note that this means the array format won't work with indirect
   for(auto it = node->second.begin(); it != node->second.end(); it++) {
-    format = DNSName(format2str(*it, ip, v6, &gl));
+    sformat = DNSName(format2str(*it, ip, v6, &gl));
 
     // see if the record can be found
-    if (this->lookup_static(dom, format, qtype, qdomain, ip, gl, v6))
+    if (this->lookup_static(dom, sformat, qtype, qdomain, ip, gl, v6))
       return;
   }
 
@@ -404,7 +404,7 @@ void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, DNSPacket
   rr.domain_id = dom.id;
   rr.qtype = QType::CNAME;
   rr.qname = qdomain;
-  rr.content = format.toString();
+  rr.content = sformat.toString();
   rr.auth = 1;
   rr.ttl = dom.ttl;
   rr.scopeMask = gl.netmask;
@@ -735,7 +735,7 @@ string GeoIPBackend::queryGeoIP(const string &ip, bool v6, GeoIPQueryAttribute a
   return ret;
 }
 
-string GeoIPBackend::format2str(string format, const string& ip, bool v6, GeoIPLookup* gl) {
+string GeoIPBackend::format2str(string sformat, const string& ip, bool v6, GeoIPLookup* gl) {
   string::size_type cur,last;
   time_t t = time((time_t*)NULL);
   GeoIPLookup tmp_gl; // largest wins
@@ -743,62 +743,62 @@ string GeoIPBackend::format2str(string format, const string& ip, bool v6, GeoIPL
   gmtime_r(&t, &gtm);
   last=0;
 
-  while((cur = format.find("%", last)) != string::npos) {
+  while((cur = sformat.find("%", last)) != string::npos) {
     string rep;
     int nrep=3;
     tmp_gl.netmask = 0;
-    if (!format.compare(cur,3,"%cn")) {
+    if (!sformat.compare(cur,3,"%cn")) {
       rep = queryGeoIP(ip, v6, Continent, &tmp_gl);
-    } else if (!format.compare(cur,3,"%co")) {
+    } else if (!sformat.compare(cur,3,"%co")) {
       rep = queryGeoIP(ip, v6, Country, &tmp_gl);
-    } else if (!format.compare(cur,3,"%cc")) {
+    } else if (!sformat.compare(cur,3,"%cc")) {
       rep = queryGeoIP(ip, v6, Country2, &tmp_gl);
-    } else if (!format.compare(cur,3,"%af")) {
+    } else if (!sformat.compare(cur,3,"%af")) {
       rep = (v6?"v6":"v4");
-    } else if (!format.compare(cur,3,"%as")) {
+    } else if (!sformat.compare(cur,3,"%as")) {
       rep = queryGeoIP(ip, v6, ASn, &tmp_gl);
-    } else if (!format.compare(cur,3,"%re")) {
+    } else if (!sformat.compare(cur,3,"%re")) {
       rep = queryGeoIP(ip, v6, Region, &tmp_gl);
-    } else if (!format.compare(cur,3,"%na")) {
+    } else if (!sformat.compare(cur,3,"%na")) {
       rep = queryGeoIP(ip, v6, Name, &tmp_gl);
-    } else if (!format.compare(cur,3,"%ci")) {
+    } else if (!sformat.compare(cur,3,"%ci")) {
       rep = queryGeoIP(ip, v6, City, &tmp_gl);
-    } else if (!format.compare(cur,3,"%hh")) {
+    } else if (!sformat.compare(cur,3,"%hh")) {
       rep = boost::str(boost::format("%02d") % gtm.tm_hour);
       tmp_gl.netmask = (v6?128:32);
-    } else if (!format.compare(cur,3,"%yy")) {
+    } else if (!sformat.compare(cur,3,"%yy")) {
       rep = boost::str(boost::format("%02d") % (gtm.tm_year + 1900));
       tmp_gl.netmask = (v6?128:32);
-    } else if (!format.compare(cur,3,"%dd")) {
+    } else if (!sformat.compare(cur,3,"%dd")) {
       rep = boost::str(boost::format("%02d") % (gtm.tm_yday + 1));
       tmp_gl.netmask = (v6?128:32);
-    } else if (!format.compare(cur,4,"%wds")) {
+    } else if (!sformat.compare(cur,4,"%wds")) {
       nrep=4;
       rep = GeoIP_WEEKDAYS[gtm.tm_wday];
       tmp_gl.netmask = (v6?128:32);
-    } else if (!format.compare(cur,4,"%mos")) {
+    } else if (!sformat.compare(cur,4,"%mos")) {
       nrep=4;
       rep = GeoIP_MONTHS[gtm.tm_mon];
       tmp_gl.netmask = (v6?128:32);
-    } else if (!format.compare(cur,3,"%wd")) {
+    } else if (!sformat.compare(cur,3,"%wd")) {
       rep = boost::str(boost::format("%02d") % (gtm.tm_wday + 1));
       tmp_gl.netmask = (v6?128:32);
-    } else if (!format.compare(cur,3,"%mo")) {
+    } else if (!sformat.compare(cur,3,"%mo")) {
       rep = boost::str(boost::format("%02d") % (gtm.tm_mon + 1));
       tmp_gl.netmask = (v6?128:32);
-    } else if (!format.compare(cur,3,"%ip")) {
+    } else if (!sformat.compare(cur,3,"%ip")) {
       rep = ip;
       tmp_gl.netmask = (v6?128:32);
-    } else if (!format.compare(cur,2,"%%")) {
+    } else if (!sformat.compare(cur,2,"%%")) {
       last = cur + 2; continue;
     } else {
       last = cur + 1; continue; 
     }
     if (tmp_gl.netmask > gl->netmask) gl->netmask = tmp_gl.netmask;
-    format.replace(cur, nrep, rep);
+    sformat.replace(cur, nrep, rep);
     last = cur + rep.size(); // move to next attribute
   }
-  return format;
+  return sformat;
 }
 
 void GeoIPBackend::reload() {
index f02d87e9dd2c7e1942b4b897f954af67b03046b1..10fb8c7dfb4161fa66013569a459aa536a6c26c5 100644 (file)
@@ -82,7 +82,6 @@ public:
     }
     d_res_set = PQexecPrepared(d_db(), d_stmt.c_str(), d_nparams, paramValues, paramLengths, NULL, 0);
     ExecStatusType status = PQresultStatus(d_res_set);
-    string errmsg(PQresultErrorMessage(d_res_set));
     if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK && status != PGRES_NONFATAL_ERROR) {
       string errmsg(PQresultErrorMessage(d_res_set));
       releaseStatement();
index 1f8677fe06446fea84346c463a1a72f8dc52ac33..ecc7e10892fb198300f6c77205fc041d3a800e2c 100644 (file)
@@ -125,8 +125,8 @@ void CoProcess::checkStatus()
     throw PDNSException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno)));
   else if(ret) {
     if(WIFEXITED(status)) {
-      int ret=WEXITSTATUS(status);
-      throw PDNSException("Coprocess exited with code "+itoa(ret));
+      int exitStatus=WEXITSTATUS(status);
+      throw PDNSException("Coprocess exited with code "+itoa(exitStatus));
     }
     if(WIFSIGNALED(status)) {
       int sig=WTERMSIG(status);
index 6cd5ae7f41a9f9d2a9835f4ca05a77ce1590f565..54cdb03199e68c5157e77d9951b14738d4a3a95f 100644 (file)
 #endif
 #include "remotebackend.hh"
 
-PipeConnector::PipeConnector(std::map<std::string,std::string> options) {
-  if (options.count("command") == 0) {
+PipeConnector::PipeConnector(std::map<std::string,std::string> optionsMap) {
+  if (optionsMap.count("command") == 0) {
     L<<Logger::Error<<"Cannot find 'command' option in connection string"<<endl;
     throw PDNSException();
   }
-  this->command = options.find("command")->second;
-  this->options = options;
+  this->command = optionsMap.find("command")->second;
+  this->options = optionsMap;
   d_timeout=2000;
 
-  if (options.find("timeout") != options.end()) {
-     d_timeout = std::stoi(options.find("timeout")->second);
+  if (optionsMap.find("timeout") != optionsMap.end()) {
+     d_timeout = std::stoi(optionsMap.find("timeout")->second);
   }
 
   d_pid = -1;
@@ -190,8 +190,8 @@ bool PipeConnector::checkStatus()
     throw PDNSException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno)));
   else if(ret) {
     if(WIFEXITED(status)) {
-      int ret=WEXITSTATUS(status);
-      throw PDNSException("Coprocess exited with code "+itoa(ret));
+      int exitStatus=WEXITSTATUS(status);
+      throw PDNSException("Coprocess exited with code "+itoa(exitStatus));
     }
     if(WIFSIGNALED(status)) {
       int sig=WTERMSIG(status);
index 92e82a975ec7d8e3fa22aa13436f1d3737af623e..8b0188cf12be83cd1ca1ee5bfb253c098005f466 100644 (file)
 #define UNIX_PATH_MAX 108
 #endif
 
-UnixsocketConnector::UnixsocketConnector(std::map<std::string,std::string> options) {
-  if (options.count("path") == 0) {
+UnixsocketConnector::UnixsocketConnector(std::map<std::string,std::string> optionsMap) {
+  if (optionsMap.count("path") == 0) {
     L<<Logger::Error<<"Cannot find 'path' option in connection string"<<endl;
     throw PDNSException();
   } 
   this->timeout = 2000;
-  if (options.find("timeout") != options.end()) { 
-    this->timeout = std::stoi(options.find("timeout")->second);
+  if (optionsMap.find("timeout") != optionsMap.end()) {
+    this->timeout = std::stoi(optionsMap.find("timeout")->second);
   }
-  this->path = options.find("path")->second;
-  this->options = options;
+  this->path = optionsMap.find("path")->second;
+  this->options = optionsMap;
   this->connected = false;
   this->fd = -1;
 }
index 5e6d4360d09bca8544f7e58fc91a61f74620d1ca..21e35add37f9beec47497f4e0a27933eaecaed70 100644 (file)
@@ -107,7 +107,7 @@ private:
 
   uint64_t d_maxEntries{0};
   time_t d_lastclean; // doesn't need to be atomic
-  unsigned long d_nextclean{4906};
+  unsigned long d_nextclean{4096};
   unsigned int d_cleaninterval{4096};
   bool d_cleanskipped{false};
 
index fcebd5a2793e26820659a71595b37827485c36ef..0edbded54622c176a551e861bbc4323e70676a04 100644 (file)
@@ -253,8 +253,8 @@ try
   while(getline(ifs, line)) {
     vector<uint8_t> packet;
     boost::trim(line);
-    auto p = splitField(line, ' ');
-    DNSPacketWriter pw(packet, DNSName(p.first), DNSRecordContent::TypeToNumber(p.second));
+    const auto fields = splitField(line, ' ');
+    DNSPacketWriter pw(packet, DNSName(fields.first), DNSRecordContent::TypeToNumber(fields.second));
     pw.getHeader()->rd=wantRecursion;
     pw.getHeader()->id=random();
     if(pw.getHeader()->id % 2) {
index 07e4a977865df5783ac9a3317268836765cd2bf3..eb4aead429e13aacc00d8fdd7af8af4c6d066a9c 100644 (file)
@@ -645,9 +645,9 @@ bool DNSSECKeeper::rectifyZone(const DNSName& zone, string& error, bool doTransa
 
   set<DNSName> nsec3set;
   if (haveNSEC3 && !narrow) {
-    for (auto &rr: rrs) {
+    for (auto &loopRR: rrs) {
       bool skip=false;
-      DNSName shorter = rr.qname;
+      DNSName shorter = loopRR.qname;
       if (shorter != zone && shorter.chopOff() && shorter != zone) {
         do {
           if(nsset.count(shorter)) {
@@ -656,8 +656,8 @@ bool DNSSECKeeper::rectifyZone(const DNSName& zone, string& error, bool doTransa
           }
         } while(shorter.chopOff() && shorter != zone);
       }
-      shorter = rr.qname;
-      if(!skip && (rr.qtype.getCode() != QType::NS || !isOptOut)) {
+      shorter = loopRR.qname;
+      if(!skip && (loopRR.qtype.getCode() != QType::NS || !isOptOut)) {
 
         do {
           if(!nsec3set.count(shorter)) {
index 6a442ac57d400fd9201f4d71ec84e2284cbd7114..c255391f1e00c0df53f007025341668b3eb322e2 100644 (file)
@@ -2477,8 +2477,8 @@ catch(const LuaContext::ExecutionErrorException& e) {
   try {
     errlog("Fatal Lua error: %s", e.what());
     std::rethrow_if_nested(e);
-  } catch(const std::exception& e) {
-    errlog("Details: %s", e.what());
+  } catch(const std::exception& ne) {
+    errlog("Details: %s", ne.what());
   }
   catch(PDNSException &ae)
   {
index 2e1135214f40519af362fcc2d618a17be1e12a18..4c5f218c99a17b890c2815c4e7fdffda05566770 100644 (file)
@@ -649,17 +649,17 @@ bool sendPacketFromPR(PcapPacketReader& pr, const ComboAddress& remote, int stam
       s_origanswers++;
       qids_t::const_iterator iter=qids.find(qi);      
       if(iter != qids.end()) {
-        QuestionData qd=*iter;
-        qd.d_origAnswers=mdp.d_answers;
-        qd.d_origRcode=mdp.d_header.rcode;
+        QuestionData eqd=*iter;
+        eqd.d_origAnswers=mdp.d_answers;
+        eqd.d_origRcode=mdp.d_header.rcode;
         
         if(!dh->ra) {
           s_norecursionavailable++;
-          qd.d_norecursionavailable=true;
+          eqd.d_norecursionavailable=true;
         }
-        qids.replace(iter, qd);
+        qids.replace(iter, eqd);
 
-        if(qd.d_newRcode!=-1) {
+        if(eqd.d_newRcode!=-1) {
           measureResultAndClean(iter);
         }
         
index 02b4a15ed29781d30e415fc2aba88789920cc306..773d71090d8c73995f6ef6ce5ff4513e4130b7f5 100644 (file)
@@ -84,8 +84,8 @@ AuthLua4::AuthLua4(const std::string& fname) {
                                                                                        cas.insert(ComboAddress(*s));
                                                                                      }
                                                                                      else if(auto v = boost::get<vector<pair<unsigned int, string> > >(&in)) {
-                                                                                       for(const auto& s : *v)
-                                                                                         cas.insert(ComboAddress(s.second));
+                                                                                       for(const auto& str : *v)
+                                                                                         cas.insert(ComboAddress(str.second));
                                                                                      }
                                                                                      else
                                                                                        cas.insert(boost::get<ComboAddress>(in));
@@ -136,8 +136,8 @@ AuthLua4::AuthLua4(const std::string& fname) {
 
       if(auto rec = std::dynamic_pointer_cast<ARecordContent>(dr.d_content))
         ret=rec->getCA(53);
-      else if(auto rec = std::dynamic_pointer_cast<AAAARecordContent>(dr.d_content))
-        ret=rec->getCA(53);
+      else if(auto aaaarec = std::dynamic_pointer_cast<AAAARecordContent>(dr.d_content))
+        ret=aaaarec->getCA(53);
       return ret;
     });
 
index b31387a73bbeb928b454e4c0476fad86feb97584..f6549691141c87a904491682906b425ee3dba1fe 100644 (file)
@@ -91,8 +91,7 @@ try
   if(res < 0) 
     throw runtime_error("reading packet from remote: "+stringerror());
     
-  string packet(buffer, res);
-  MOADNSParser mdp(true, packet);
+  MOADNSParser mdp(true, string(buffer,res));
   nif.domain = mdp.d_qname;
   nif.origID = mdp.d_header.id;
 
index a26e87b0286c145391eb57c6b3bdb62ea5f037b8..82345f53294774d56e5a28d127d2f0682d4829ee 100644 (file)
@@ -212,17 +212,17 @@ try
   set<DNSName> proven;
   set<DNSName> denied;
   namesseen.insert(qname);
-  for(const auto &n: namesseen)
+  for(const auto &name: namesseen)
   {
-    DNSName shorter(n);
+    DNSName shorter(name);
     do {
       namestocheck.insert(shorter);
     } while(shorter.chopOff());
   }
-  for(const auto &n: namestocheck)
+  for(const auto &name: namestocheck)
   {
-    proveOrDeny(nsec3s, n, nsec3salt, nsec3iters, proven, denied);
-    proveOrDeny(nsec3s, g_wildcarddnsname+n, nsec3salt, nsec3iters, proven, denied);
+    proveOrDeny(nsec3s, name, nsec3salt, nsec3iters, proven, denied);
+    proveOrDeny(nsec3s, g_wildcarddnsname+name, nsec3salt, nsec3iters, proven, denied);
   }
 
   if(names.count(qname))
index dd33e75a9c8a0ce934e8163debd04c075414fe5a..3b3bcbd161d6ce7772d49e14fd8610944cb4df36 100644 (file)
@@ -582,7 +582,6 @@ void PacketHandler::addNSEC3(DNSPacket *p, DNSPacket *r, const DNSName& target,
   bool doNextcloser = false;
   string before, after, hashed;
   DNSName unhashed, closest;
-  DNSZoneRecord rr;
 
   if (mode == 2 || mode == 3 || mode == 4) {
     closest=wildcard;
@@ -622,8 +621,7 @@ void PacketHandler::addNSEC3(DNSPacket *p, DNSPacket *r, const DNSName& target,
     if (!after.empty()) {
       DLOG(L<<"Done calling for matching, hashed: '"<<toBase32Hex(hashed)<<"' before='"<<toBase32Hex(before)<<"', after='"<<toBase32Hex(after)<<"'"<<endl);
       emitNSEC3(r, sd, ns3rc, unhashed, before, after, mode);
-    } else if(!before.empty())
-      r->addRecord(rr);
+    }
   }
 
   // add covering NSEC3 RR
@@ -1382,10 +1380,10 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
     }
                                        
     if(weRedirected) {
-      for(auto& rr: rrset) {
-        if(rr.dr.d_type == QType::CNAME) {
-          r->addRecord(rr);
-          target = getRR<CNAMERecordContent>(rr.dr)->getTarget();
+      for(auto& loopRR: rrset) {
+        if(loopRR.dr.d_type == QType::CNAME) {
+          r->addRecord(loopRR);
+          target = getRR<CNAMERecordContent>(loopRR.dr)->getTarget();
           retargetcount++;
           goto retargeted;
         }
@@ -1393,9 +1391,9 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
     }
     else if(weDone) {
       bool haveRecords = false;
-      for(const auto& rr: rrset) {
-        if((p->qtype.getCode() == QType::ANY || rr.dr.d_type == p->qtype.getCode()) && rr.dr.d_type && rr.dr.d_type != QType::ALIAS && rr.auth) {
-          r->addRecord(rr);
+      for(const auto& loopRR: rrset) {
+        if((p->qtype.getCode() == QType::ANY || loopRR.dr.d_type == p->qtype.getCode()) && loopRR.dr.d_type && loopRR.dr.d_type != QType::ALIAS && loopRR.auth) {
+          r->addRecord(loopRR);
           haveRecords = true;
         }
       }
@@ -1433,8 +1431,8 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
 
     editSOA(d_dk, sd.qname, r);
     
-    for(const auto& rr: r->getRRS()) {
-      if(rr.scopeMask) {
+    for(const auto& loopRR: r->getRRS()) {
+      if(loopRR.scopeMask) {
         noCache=true;
         break;
       }
index 6ea920f863916ed6221021ab69b2617668fde0cc..64efdd7581263cd4ca89258f362bc25cf4687708 100644 (file)
@@ -1267,8 +1267,8 @@ static void startDoResolve(void *p)
     // Luawrapper nests the exception from Lua, so we unnest it here
     try {
         std::rethrow_if_nested(e);
-    } catch(const std::exception& e) {
-        L<<". Extra info: "<<e.what();
+    } catch(const std::exception& ne) {
+        L<<". Extra info: "<<ne.what();
     } catch(...) {}
 
     L<<endl;
index 7e8f1caf34407736b922a6e425345c37c3e2170d..50e7d7600b1b2163db4aa4aa0d8261b09a357bf0 100644 (file)
@@ -219,7 +219,6 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vect
   bool presigned=dk.isPresigned(zone);
   bool validKeys=dk.checkKeys(zone);
 
-  DNSResourceRecord rr;
   uint64_t numrecords=0, numerrors=0, numwarnings=0;
 
   if (haveNSEC3) {
@@ -276,9 +275,10 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vect
 
   vector<DNSResourceRecord> records;
   if(!suppliedrecords) {
+    DNSResourceRecord drr;
     sd.db->list(zone, sd.domain_id, g_verbose);
-    while(sd.db->get(rr)) {
-      records.push_back(rr);
+    while(sd.db->get(drr)) {
+      records.push_back(drr);
     }
   }
   else 
@@ -841,11 +841,11 @@ int editZone(DNSSECKeeper& dk, const DNSName &zone) {
   }
   cmdline.clear();
   ZoneParserTNG zpt(tmpnam, g_rootdnsname);
-  DNSResourceRecord rr;
+  DNSResourceRecord zrr;
   map<pair<DNSName,uint16_t>, vector<DNSRecord> > grouped;
-  while(zpt.get(rr)) {
+  while(zpt.get(zrr)) {
     try {
-      DNSRecord dr(rr);
+      DNSRecord dr(zrr);
       post.push_back(dr);
       grouped[{dr.d_name,dr.d_type}].push_back(dr);
     }
@@ -923,14 +923,14 @@ int editZone(DNSSECKeeper& dk, const DNSName &zone) {
   else if(changed.empty() || c!='a')
     goto reAsk2;
 
-  for(const auto& c : changed) {
+  for(const auto& change : changed) {
     vector<DNSResourceRecord> vrr;
-    for(const DNSRecord& rr : grouped[c.first]) {
-      DNSResourceRecord drr = DNSResourceRecord::fromWire(rr);
-      drr.domain_id = di.id;
-      vrr.push_back(drr);
+    for(const DNSRecord& rr : grouped[change.first]) {
+      DNSResourceRecord crr = DNSResourceRecord::fromWire(rr);
+      crr.domain_id = di.id;
+      vrr.push_back(crr);
     }
-    di.backend->replaceRRSet(di.id, c.first.first, QType(c.first.second), vrr);
+    di.backend->replaceRRSet(di.id, change.first.first, QType(change.first.second), vrr);
   }
   rectifyZone(dk, zone);
   return EXIT_SUCCESS;
index 7b9ff813972c0a76edcfabc1c25fe34bb513fdb6..045bae2b52de73049e077c35eff986798581ec84 100644 (file)
@@ -74,27 +74,27 @@ protected:
     buflen = 0;
   };
 public:
-  P11KitAttribute(CK_ATTRIBUTE_TYPE type, const std::string& value) {
+  P11KitAttribute(CK_ATTRIBUTE_TYPE type_, const std::string& value) {
     Init();
-    this->type = type;
+    this->type = type_;
     setString(value);
   }
 
-  P11KitAttribute(CK_ATTRIBUTE_TYPE type, char value) {
+  P11KitAttribute(CK_ATTRIBUTE_TYPE type_, char value) {
     Init();
-    this->type = type;
+    this->type = type_;
     setByte(value);
   }
 
-  P11KitAttribute(CK_ATTRIBUTE_TYPE type, unsigned char value) {
+  P11KitAttribute(CK_ATTRIBUTE_TYPE type_, unsigned char value) {
     Init();
-    this->type = type;
+    this->type = type_;
     setByte(value);
   }
 
-  P11KitAttribute(CK_ATTRIBUTE_TYPE type, unsigned long value) {
+  P11KitAttribute(CK_ATTRIBUTE_TYPE type_, unsigned long value) {
     Init();
-    this->type = type;
+    this->type = type_;
     setLong(value);
   }
 
@@ -571,9 +571,9 @@ class Pkcs11Token {
       }
 
       // then allocate memory
-      for(size_t k=0; k < attributes.size(); k++) {
-        if (attributes[k].valueType() == Attribute_String) {
-          attr[k].pValue = attributes[k].allocate(attr[k].ulValueLen);
+      for(size_t idx=0; idx < attributes.size(); idx++) {
+        if (attributes[idx].valueType() == Attribute_String) {
+          attr[idx].pValue = attributes[idx].allocate(attr[idx].ulValueLen);
         }
       }
 
@@ -582,9 +582,9 @@ class Pkcs11Token {
       logError("C_GetAttributeValue");
 
       // copy values to map and release allocated memory
-      for(size_t k=0; k < attributes.size(); k++) {
-        if (attributes[k].valueType() == Attribute_String) {
-          attributes[k].commit(attr[k].ulValueLen);
+      for(size_t idx=0; idx < attributes.size(); idx++) {
+        if (attributes[idx].valueType() == Attribute_String) {
+          attributes[idx].commit(attr[idx].ulValueLen);
         }
       }
 
index 5ea108cb0774b6c7ef94a8672e5f6ce5e0a3c2c1..7d42aa03faf1b68f44fb042395ba50c7a918b6cc 100644 (file)
@@ -574,12 +574,12 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) {
   size_t found = 0;
   for (size_t i = 0; i <= 255; i++) {
     retrieved.clear();
-    ComboAddress who("192.0.2." + std::to_string(i));
+    ComboAddress whoLoop("192.0.2." + std::to_string(i));
 
-    auto ret = MRC.get(now, power1, QType(QType::A), false, &retrieved, who);
+    auto ret = MRC.get(now, power1, QType(QType::A), false, &retrieved, whoLoop);
     if (ret > 0) {
       BOOST_REQUIRE_EQUAL(retrieved.size(), 1);
-      BOOST_CHECK_EQUAL(getRR<ARecordContent>(retrieved.at(0))->getCA().toString(), who.toString());
+      BOOST_CHECK_EQUAL(getRR<ARecordContent>(retrieved.at(0))->getCA().toString(), whoLoop.toString());
       found++;
     }
     else {
index 3527a1770c8b69436ab47b9a094197ab18100ca1..c473ea82a7af50be137c4e5da7e3f40ffe507958 100644 (file)
@@ -1911,7 +1911,6 @@ BOOST_AUTO_TEST_CASE(test_no_rd) {
 
 BOOST_AUTO_TEST_CASE(test_cache_min_max_ttl) {
   std::unique_ptr<SyncRes> sr;
-  const time_t now = time(nullptr);
   initSR(sr);
 
   primeHints();
@@ -1938,6 +1937,7 @@ BOOST_AUTO_TEST_CASE(test_cache_min_max_ttl) {
       return 0;
     });
 
+  const time_t now = time(nullptr);
   SyncRes::s_minimumTTL = 60;
   SyncRes::s_maxcachettl = 3600;
 
@@ -7343,7 +7343,6 @@ BOOST_AUTO_TEST_CASE(test_nsec3_insecure_delegation_denial) {
 
 BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_negcache_validity) {
   std::unique_ptr<SyncRes> sr;
-  const time_t now = time(nullptr);
   initSR(sr, true);
 
   setDNSSECValidation(sr, DNSSECMode::ValidateAll);
@@ -7381,6 +7380,7 @@ BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_negcache_validity) {
       return 0;
     });
 
+  const time_t now = time(nullptr);
   vector<DNSRecord> ret;
   int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
   BOOST_CHECK_EQUAL(res, RCode::NoError);
@@ -7409,7 +7409,6 @@ BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_negcache_validity) {
 
 BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_cache_validity) {
   std::unique_ptr<SyncRes> sr;
-  const time_t now = time(nullptr);
   initSR(sr, true);
 
   setDNSSECValidation(sr, DNSSECMode::ValidateAll);
@@ -7446,6 +7445,7 @@ BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_cache_validity) {
       return 0;
     });
 
+  const time_t now = time(nullptr);
   vector<DNSRecord> ret;
   int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
   BOOST_CHECK_EQUAL(res, RCode::NoError);
index 38ba5590fe4a82a95c1f0268d566de8dc2b4d988..9b18d422e7fffb8e50092d8c179776a08fae8106 100644 (file)
@@ -204,9 +204,7 @@ try
       n+=numread;
     }
 
-    string packet = string(creply, len);
-
-    MOADNSParser mdp(false, packet);
+    MOADNSParser mdp(false, string(creply, len));
     if (mdp.d_header.rcode != 0) {
       throw PDNSException(string("Remote server refused: ") + std::to_string(mdp.d_header.rcode));
     }
index 7a6959dd3a2b70a1916a232664a484dc49a2de6a..d33836438328623c7dbc635be86d1759e0eb2ac4 100644 (file)
@@ -88,8 +88,9 @@ void StatNode::submit(deque<string>& labels, const std::string& domain, int rcod
     name=labels.back();
     //    cerr<<"Set short name to '"<<name<<"'"<<endl;
   }
-  else 
-    ; //    cerr<<"Short name was already set to '"<<name<<"'"<<endl;
+  else {
+    //    cerr<<"Short name was already set to '"<<name<<"'"<<endl;
+  }
 
   if(labels.size()==1) {
     if (fullname.empty()) {
index f5cbe00732382b3bc67745cec9a7ee195ce7ad3f..039c4390d7933cb81068b5da819035f016d9bf5b 100644 (file)
@@ -871,9 +871,9 @@ bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector
         }
 
         for(const auto& rec : authorityRecs) {
-          DNSRecord dr(*rec);
-          dr.d_ttl=j->d_ttl - d_now.tv_sec;
-          ret.push_back(dr);
+          DNSRecord authDR(*rec);
+          authDR.d_ttl=j->d_ttl - d_now.tv_sec;
+          ret.push_back(authDR);
         }
 
         if(qtype != QType::CNAME) { // perhaps they really wanted a CNAME!
@@ -1559,8 +1559,8 @@ void SyncRes::computeZoneCuts(const DNSName& begin, const DNSName& end, unsigned
        just look for (N)TA
     */
     if (cutState == Insecure || cutState == Bogus) {
-      dsmap_t ds;
-      vState newState = getDSRecords(qname, ds, true, depth);
+      dsmap_t cutDS;
+      vState newState = getDSRecords(qname, cutDS, true, depth);
       if (newState == Indeterminate) {
         continue;
       }
index 394fa9fb1f9dfecda44c749431ff9179f0094897..cc0011ed815cd1def2561a38d0a25ab207e7148f 100644 (file)
@@ -815,15 +815,15 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr<DNSPacket> q, int ou
 
   if(rectify) {
     // set auth
-    for(DNSZoneRecord &zrr :  zrrs) {
-      zrr.auth=true;
-      if (zrr.dr.d_type != QType::NS || zrr.dr.d_name!=target) {
-        DNSName shorter(zrr.dr.d_name);
+    for(DNSZoneRecord &loopZRR :  zrrs) {
+      loopZRR.auth=true;
+      if (loopZRR.dr.d_type != QType::NS || loopZRR.dr.d_name!=target) {
+        DNSName shorter(loopZRR.dr.d_name);
         do {
           if (shorter==target) // apex is always auth
             break;
-          if(nsset.count(shorter) && !(zrr.dr.d_name==shorter && zrr.dr.d_type == QType::DS)) {
-            zrr.auth=false;
+          if(nsset.count(shorter) && !(loopZRR.dr.d_name==shorter && loopZRR.dr.d_type == QType::DS)) {
+            loopZRR.auth=false;
             break;
           }
         } while(shorter.chopOff());
@@ -834,9 +834,9 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr<DNSPacket> q, int ou
       // ents are only required for NSEC3 zones
       uint32_t maxent = ::arg().asNum("max-ent-entries");
       set<DNSName> nsec3set, nonterm;
-      for (auto &zrr: zrrs) {
+      for (auto &loopZRR: zrrs) {
         bool skip=false;
-        DNSName shorter = zrr.dr.d_name;
+        DNSName shorter = loopZRR.dr.d_name;
         if (shorter != target && shorter.chopOff() && shorter != target) {
           do {
             if(nsset.count(shorter)) {
@@ -845,8 +845,8 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr<DNSPacket> q, int ou
             }
           } while(shorter.chopOff() && shorter != target);
         }
-        shorter = zrr.dr.d_name;
-        if(!skip && (zrr.dr.d_type != QType::NS || !ns3pr.d_flags)) {
+        shorter = loopZRR.dr.d_name;
+        if(!skip && (loopZRR.dr.d_type != QType::NS || !ns3pr.d_flags)) {
           do {
             if(!nsec3set.count(shorter)) {
               nsec3set.insert(shorter);
@@ -855,8 +855,8 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr<DNSPacket> q, int ou
         }
       }
 
-      for(DNSZoneRecord &zrr :  zrrs) {
-        DNSName shorter(zrr.dr.d_name);
+      for(DNSZoneRecord &loopZRR :  zrrs) {
+        DNSName shorter(loopZRR.dr.d_name);
         while(shorter != target && shorter.chopOff()) {
           if(!qnames.count(shorter) && !nonterm.count(shorter) && nsec3set.count(shorter)) {
             if(!(maxent)) {
@@ -870,11 +870,11 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr<DNSPacket> q, int ou
       }
 
       for(const auto& nt :  nonterm) {
-        DNSZoneRecord zrr;
-        zrr.dr.d_name=nt;
-        zrr.dr.d_type=QType::ENT;
-        zrr.auth=true;
-        zrrs.push_back(zrr);
+        DNSZoneRecord tempRR;
+        tempRR.dr.d_name=nt;
+        tempRR.dr.d_type=QType::ENT;
+        tempRR.auth=true;
+        zrrs.push_back(tempRR);
       }
     }
   }
@@ -888,39 +888,39 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr<DNSPacket> q, int ou
   DTime dt;
   dt.set();
   int records=0;
-  for(DNSZoneRecord &zrr :  zrrs) {
-    if (zrr.dr.d_type == QType::RRSIG) {
-      if(presignedZone && NSEC3Zone && getRR<RRSIGRecordContent>(zrr.dr)->d_type == QType::NSEC3) {
-        ns3rrs.insert(zrr.dr.d_name.makeRelative(sd.qname));
+  for(DNSZoneRecord &loopZRR :  zrrs) {
+    if (loopZRR.dr.d_type == QType::RRSIG) {
+      if(presignedZone && NSEC3Zone && getRR<RRSIGRecordContent>(loopZRR.dr)->d_type == QType::NSEC3) {
+        ns3rrs.insert(loopZRR.dr.d_name.makeRelative(sd.qname));
       }
       continue;
     }
 
     // only skip the DNSKEY, CDNSKEY and CDS if direct-dnskey is enabled, to avoid changing behaviour
     // when it is not enabled.
-    if(::arg().mustDo("direct-dnskey") && (zrr.dr.d_type == QType::DNSKEY || zrr.dr.d_type == QType::CDNSKEY || zrr.dr.d_type == QType::CDS))
+    if(::arg().mustDo("direct-dnskey") && (loopZRR.dr.d_type == QType::DNSKEY || loopZRR.dr.d_type == QType::CDNSKEY || loopZRR.dr.d_type == QType::CDS))
       continue;
 
     records++;
-    if(securedZone && (zrr.auth || zrr.dr.d_type == QType::NS)) {
-      if (NSEC3Zone || zrr.dr.d_type) {
-        keyname = NSEC3Zone ? DNSName(toBase32Hex(hashQNameWithSalt(ns3pr, zrr.dr.d_name))) : zrr.dr.d_name;
+    if(securedZone && (loopZRR.auth || loopZRR.dr.d_type == QType::NS)) {
+      if (NSEC3Zone || loopZRR.dr.d_type) {
+        keyname = NSEC3Zone ? DNSName(toBase32Hex(hashQNameWithSalt(ns3pr, loopZRR.dr.d_name))) : loopZRR.dr.d_name;
         NSECXEntry& ne = nsecxrepo[keyname];
         ne.d_ttl = sd.default_ttl;
-        ne.d_auth = (ne.d_auth || zrr.auth || (NSEC3Zone && (!ns3pr.d_flags || (presignedZone && ns3pr.d_flags))));
-        if (zrr.dr.d_type) {
-          ne.d_set.insert(zrr.dr.d_type);
+        ne.d_auth = (ne.d_auth || loopZRR.auth || (NSEC3Zone && (!ns3pr.d_flags || (presignedZone && ns3pr.d_flags))));
+        if (loopZRR.dr.d_type) {
+          ne.d_set.insert(loopZRR.dr.d_type);
         }
       }
     }
 
-    if (!zrr.dr.d_type)
+    if (!loopZRR.dr.d_type)
       continue; // skip empty non-terminals
 
-    if(zrr.dr.d_type == QType::SOA)
+    if(loopZRR.dr.d_type == QType::SOA)
       continue; // skip SOA - would indicate end of AXFR
 
-    if(csp.submit(zrr)) {
+    if(csp.submit(loopZRR)) {
       for(;;) {
         outpacket->getRRS() = csp.getChunk();
         if(!outpacket->getRRS().empty()) {
index 771bfb84bd448a320a5f8cb425ed5e1394bbd8e6..7200454c8cff226f30eb86886529cac2d8f12cbd 100644 (file)
@@ -390,7 +390,7 @@ BOOST_AUTO_TEST_CASE(test_QuestionHash) {
  
   for(unsigned int n=0; n < 100000; ++n) {
     packet.clear();
-    DNSPacketWriter dpw1(packet, DNSName(std::to_string(n)+"."+std::to_string(n*2)+"."), QType::AAAA);
+    DNSPacketWriter dpw3(packet, DNSName(std::to_string(n)+"."+std::to_string(n*2)+"."), QType::AAAA);
     counts[hashQuestion((char*)&packet[0], packet.size(), 0) % counts.size()]++;
   }
   
@@ -597,17 +597,17 @@ BOOST_AUTO_TEST_CASE(test_compare_canonical) {
   BOOST_CHECK(!a(DNSName("www.powerdns.net"), g_rootdnsname));
 
   vector<DNSName> vec;
-  for(const std::string& a : {"bert.com.", "alpha.nl.", "articles.xxx.",
+  for(const std::string& b : {"bert.com.", "alpha.nl.", "articles.xxx.",
        "Aleph1.powerdns.com.", "ZOMG.powerdns.com.", "aaa.XXX.", "yyy.XXX.", 
        "test.powerdns.com.", "\\128.com"}) {
-    vec.push_back(DNSName(a));
+    vec.push_back(DNSName(b));
   }
   sort(vec.begin(), vec.end(), CanonDNSNameCompare());
   //  for(const auto& v : vec)
   //    cerr<<'"'<<v.toString()<<'"'<<endl;
 
   vector<DNSName> right;
-  for(const auto& a: {"bert.com.",  "Aleph1.powerdns.com.",
+  for(const auto& b: {"bert.com.",  "Aleph1.powerdns.com.",
        "test.powerdns.com.",
        "ZOMG.powerdns.com.",
        "\\128.com.",
@@ -615,7 +615,7 @@ BOOST_AUTO_TEST_CASE(test_compare_canonical) {
        "aaa.XXX.",
        "articles.xxx.",
        "yyy.XXX."})
-    right.push_back(DNSName(a));
+    right.push_back(DNSName(b));
 
   
   BOOST_CHECK(vec==right);
index 54351e3301076d61056b3cd37de5acd90ddeb5b1..913063c59aebf366e33b34430875e5b30bdac5d5 100644 (file)
@@ -195,11 +195,11 @@ bool ZoneParserTNG::getTemplateLine()
         char radix='d';
         sscanf(spec.c_str(), "%d,%d,%c", &offset, &width, &radix);  // parse format specifier
 
-        char format[12];
-        snprintf(format, sizeof(format) - 1, "%%0%d%c", width, radix); // make into printf-style format
+        char sformat[12];
+        snprintf(sformat, sizeof(sformat) - 1, "%%0%d%c", width, radix); // make into printf-style format
 
         char tmp[80];
-        snprintf(tmp, sizeof(tmp)-1, format, d_templatecounter + offset); // and do the actual printing
+        snprintf(tmp, sizeof(tmp)-1, sformat, d_templatecounter + offset); // and do the actual printing
         outpart+=tmp;
       }
       else