]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
clang-tidy: use bool literals
authorRosen Penev <rosenp@gmail.com>
Thu, 5 Nov 2020 07:53:05 +0000 (23:53 -0800)
committerRosen Penev <rosenp@gmail.com>
Fri, 5 Feb 2021 01:22:40 +0000 (17:22 -0800)
Found with modernize-use-bool-literals

Signed-off-by: Rosen Penev <rosenp@gmail.com>
12 files changed:
modules/pipebackend/pipebackend.cc
modules/randombackend/randombackend.cc
pdns/backends/gsql/gsqlbackend.cc
pdns/dnspacket.cc
pdns/dnssecsigner.cc
pdns/nameserver.cc
pdns/packethandler.cc
pdns/pdnsutil.cc
pdns/serialtweaker.cc
pdns/ueberbackend.cc
pdns/ws-auth.cc
pdns/zone2sql.cc

index 208ef2e5d4f0987006db807f19dd98a1ad1a88ec..c8e9a77c2b12fb5d7895ca3190b54f0fa3a836e4 100644 (file)
@@ -307,7 +307,7 @@ bool PipeBackend::get(DNSResourceRecord &r)
            r.auth = (parts[2] == "1");
          } else {
            r.scopeMask = 0;
-           r.auth = 1;
+           r.auth = true;
          }
          r.qname=DNSName(parts[1+extraFields]);
          r.qtype=parts[3+extraFields];
index 20b179b8d3a2df721e8b1a1e658bb52f1299f531..71028a08410c85db6e319fb5e645010905f48ceb 100644 (file)
@@ -83,7 +83,7 @@ public:
     }
     rr.qclass=QClass::IN;   // Internet class randomness.
     rr.ttl=5;               // 5 seconds
-    rr.auth = 1;            // it may be random.. but it is auth!
+    rr.auth = true;            // it may be random.. but it is auth!
     rr.content = d_answer;
 
     d_answer.clear();       // this was the last answer
index 315c64af46bae278d775fc8bb818977bb289d3f2..776dd55a25fba1da266630521f2a252199bded56 100644 (file)
@@ -1881,7 +1881,7 @@ void GSQLBackend::extractRecord(SSqlStatement::row_t& row, DNSResourceRecord& r)
   if(d_dnssecQueries)
     r.auth = !row[7].empty() && row[7][0]=='1';
   else
-    r.auth = 1;
+    r.auth = true;
 
   r.disabled = !row[5].empty() && row[5][0]=='1';
 
index 0d527ff4ba03929909583d8484cdcf99dae90afb..15d5913307a782d11b2119099cc2a90b68b76068 100644 (file)
@@ -358,7 +358,7 @@ std::unique_ptr<DNSPacket> DNSPacket::replyPacket() const
   r->setRemote(&d_remote);
   r->setAnswer(true);  // this implies the allocation of the header
   r->setA(true); // and we are authoritative
-  r->setRA(0); // no recursion available
+  r->setRA(false); // no recursion available
   r->setRD(d.rd); // if you wanted to recurse, answer will say you wanted it 
   r->setID(d.id);
   r->setOpcode(d.opcode);
index 2a9eb764d7f0e7b0ecb26ae6198024cf2758cff2..88ebcf4d56c910e9941272307f588f18d09a883f 100644 (file)
@@ -64,7 +64,7 @@ static void fillOutRRSIG(DNSSECPrivateKey& dpk, const DNSName& signQName, RRSIGR
   string msg=getMessageForRRSET(signQName, rrc, toSign); // this is what we will hash & sign
   pair<string, string> lookup(rc->getPubKeyHash(), getLookupKey(msg));  // this hash is a memory saving exercise
 
-  bool doCache=1;
+  bool doCache=true;
   if(doCache)
   {
     ReadLock l(&g_signatures_lock);
index 6d658155a3df88dbd88ca6765199d88d445bc806..5dff5148a446555e08e7865b95b3cc4bf76a263e 100644 (file)
@@ -278,7 +278,7 @@ bool UDPNameserver::receive(DNSPacket& packet, std::string& buffer)
       if((len=recvmsg(sock, &msgh, 0)) < 0 ) {
         if(errno != EAGAIN)
           g_log<<Logger::Error<<"recvfrom gave error, ignoring: "<<stringerror()<<endl;
-        return 0;
+        return false;
       }
       break;
     }
@@ -291,7 +291,7 @@ bool UDPNameserver::receive(DNSPacket& packet, std::string& buffer)
   BOOST_STATIC_ASSERT(offsetof(sockaddr_in, sin_port) == offsetof(sockaddr_in6, sin6_port));
 
   if(remote.sin4.sin_port == 0) // would generate error on responding. sin4 also works for ipv6
-    return 0;
+    return false;
   
   packet.setSocket(sock);
   packet.setRemote(&remote);
index e6ba80759b5b2c967367f373abeca58b8536cfb0..0a991632539b5c2582707bebce2761fa4a94c7a9 100644 (file)
@@ -354,7 +354,7 @@ vector<DNSZoneRecord> PacketHandler::getBestDNAMESynth(DNSPacket& p, DNSName &ta
       rr.dr.d_type = QType::CNAME;
       rr.dr.d_name = prefix + rr.dr.d_name;
       rr.dr.d_content = std::make_shared<CNAMERecordContent>(CNAMERecordContent(prefix + getRR<DNAMERecordContent>(rr.dr)->getTarget()));
-      rr.auth = 0; // don't sign CNAME
+      rr.auth = false; // don't sign CNAME
       target= getRR<CNAMERecordContent>(rr.dr)->getTarget();
       ret.push_back(rr); 
     }
@@ -1180,7 +1180,7 @@ std::unique_ptr<DNSPacket> PacketHandler::doQuestion(DNSPacket& p)
   set<DNSName> authSet;
 
   vector<DNSZoneRecord> rrset;
-  bool weDone=0, weRedirected=0, weHaveUnauth=0, doSigs=0;
+  bool weDone=false, weRedirected=false, weHaveUnauth=false, doSigs=false;
   DNSName haveAlias;
   uint8_t aliasScopeMask;
 
@@ -1431,9 +1431,9 @@ std::unique_ptr<DNSPacket> PacketHandler::doQuestion(DNSPacket& p)
                 rrset.push_back(rr);
               }
               if(rec->d_type == QType::CNAME && p.qtype.getCode() != QType::CNAME)
-                weRedirected = 1;
+                weRedirected = true;
               else
-                weDone = 1;
+                weDone = true;
             }
           }
           catch(std::exception &e) {
@@ -1455,13 +1455,13 @@ std::unique_ptr<DNSPacket> PacketHandler::doQuestion(DNSPacket& p)
 
       // cerr<<"Auth: "<<rr.auth<<", "<<(rr.dr.d_type == p.qtype)<<", "<<rr.dr.d_type.getName()<<endl;
       if((p.qtype.getCode() == QType::ANY || rr.dr.d_type == p.qtype.getCode()) && rr.auth) 
-        weDone=1;
+        weDone=true;
       // the line below fakes 'unauth NS' for delegations for non-DNSSEC backends.
       if((rr.dr.d_type == p.qtype.getCode() && !rr.auth) || (rr.dr.d_type == QType::NS && (!rr.auth || !(d_sd.qname==rr.dr.d_name))))
-        weHaveUnauth=1;
+        weHaveUnauth=true;
 
       if(rr.dr.d_type == QType::CNAME && p.qtype.getCode() != QType::CNAME) 
-        weRedirected=1;
+        weRedirected=true;
 
       if(DP && rr.dr.d_type == QType::ALIAS && (p.qtype.getCode() == QType::A || p.qtype.getCode() == QType::AAAA || p.qtype.getCode() == QType::ANY)) {
         if (!d_doExpandALIAS) {
index 78fc8990075c8ea9c3116e5f85559a2de2bbb7ca..f093827c2ecb2addda7c65062f83368e6e5ff72c 100644 (file)
@@ -1277,7 +1277,7 @@ static int createZone(const DNSName &zone, const DNSName& nsname) {
 
   DNSResourceRecord rr;
   rr.qname = zone;
-  rr.auth = 1;
+  rr.auth = true;
   rr.ttl = ::arg().asNum("default-ttl");
   rr.qtype = "SOA";
 
@@ -1365,7 +1365,7 @@ static int addOrReplaceRecord(bool addOrReplace, const vector<string>& cmds) {
     cerr<<"Domain '"<<zone<<"' does not exist"<<endl;
     return EXIT_FAILURE;
   }
-  rr.auth = 1;
+  rr.auth = true;
   rr.domain_id = di.id;
   rr.qname = name;
   DNSResourceRecord oldrr;
@@ -1528,7 +1528,7 @@ static void testSpeed(DNSSECKeeper& dk, const DNSName& zone, const string& remot
   rr.qname=DNSName("blah")+zone;
   rr.qtype=QType::A;
   rr.ttl=3600;
-  rr.auth=1;
+  rr.auth=true;
   rr.qclass = QClass::IN;
 
   UeberBackend db("key-only");
@@ -1538,7 +1538,7 @@ static void testSpeed(DNSSECKeeper& dk, const DNSName& zone, const string& remot
     throw runtime_error("No backends available for DNSSEC key storage");
   }
 
-  ChunkedSigningPipe csp(DNSName(zone), 1, cores);
+  ChunkedSigningPipe csp(DNSName(zone), true, cores);
 
   vector<DNSZoneRecord> signatures;
   uint32_t rnd;
@@ -1986,7 +1986,7 @@ static int testSchema(DNSSECKeeper& dk, const DNSName& zone)
   rr.qname=zone;
   rr.ttl=86400;
   rr.domain_id=di.id;
-  rr.auth=1;
+  rr.auth=true;
   rr.content="ns1.example.com. ahu.example.com. 2012081039 7200 3600 1209600 3600";
   cout<<"Feeding SOA"<<endl;
   db->feedRecord(rr, DNSName());
@@ -2023,7 +2023,7 @@ static int testSchema(DNSSECKeeper& dk, const DNSName& zone)
   rr.qname=zone;
   rr.ttl=86400;
   rr.domain_id=di.id;
-  rr.auth=1;
+  rr.auth=true;
   rr.content="ns1.example.com. ahu.example.com. 2012081039 7200 3600 1209600 3600";
   cout<<"Feeding SOA"<<endl;
   db->feedRecord(rr, DNSName());
@@ -3026,13 +3026,13 @@ try
       else if(pdns_iequals(cmds[n], "KSK"))
         dpk.d_flags = 257;
       else if(pdns_iequals(cmds[n], "active"))
-        active = 1;
+        active = true;
       else if(pdns_iequals(cmds[n], "passive") || pdns_iequals(cmds[n], "inactive")) // passive eventually needs to be removed
-        active = 0;
+        active = false;
       else if(pdns_iequals(cmds[n], "published"))
-        published = 1;
+        published = true;
       else if(pdns_iequals(cmds[n], "unpublished"))
-        published = 0;
+        published = false;
       else {
         cerr<<"Unknown key flag '"<<cmds[n]<<"'"<<endl;
         return 1;
index b4573b9c275ebe341d0e7d0d4af5e1f834a88d3e..1409c8d68d14161f0f107e9972652dfbdb8e9ec8 100644 (file)
@@ -155,7 +155,7 @@ bool makeIncreasedSOARecord(SOAData& sd, const string& increaseKind, const strin
   rrout.content = makeSOAContent(sd)->getZoneRepresentation(true);
   rrout.qtype = QType::SOA;
   rrout.domain_id = sd.domain_id;
-  rrout.auth = 1;
+  rrout.auth = true;
   rrout.ttl = sd.ttl;
 
   return true;
index ca4720c0983213f9001c2f12c87ab944a17bb34f..cc4d1d0ed956e263c61c8c817dfa679b631d1de7 100644 (file)
@@ -479,8 +479,8 @@ UeberBackend::UeberBackend(const string &pname)
     instances.push_back(this); // report to the static list of ourself
   }
 
-  d_negcached=0;
-  d_cached=0;
+  d_negcached=false;
+  d_cached=false;
   d_cache_ttl = ::arg().asNum("query-cache-ttl");
   d_negcache_ttl = ::arg().asNum("negquery-cache-ttl");
   d_qtype = 0;
index 32b3d37ac7848f2329cce513e6b0ae8df62a7ca5..9a43f04480221739139d38082facbd9400ea6ef4 100644 (file)
@@ -520,7 +520,7 @@ static void gatherRecords(UeberBackend& B, const string& logprefix, const Json c
   DNSResourceRecord rr;
   rr.qname = qname;
   rr.qtype = qtype;
-  rr.auth = 1;
+  rr.auth = true;
   rr.ttl = ttl;
 
   validateGatheredRRType(rr);
@@ -1640,7 +1640,7 @@ static void apiServerZones(HttpRequest* req, HttpResponse* resp) {
     // synthesize RRs as needed
     DNSResourceRecord autorr;
     autorr.qname = zonename;
-    autorr.auth = 1;
+    autorr.auth = true;
     autorr.ttl = ::arg().asNum("default-ttl");
 
     if (!have_soa && zonekind != DomainInfo::Slave) {
index 2683f09ed9d88c6bb7ad600c30abc83afdd56877..d52e5f38a7291c58dd98a85f87fa770910d9f4b9 100644 (file)
@@ -103,7 +103,7 @@ static void startNewTransaction()
       cout<<"COMMIT;"<<endl;
     }
   }
-  g_intransaction=1;
+  g_intransaction=true;
   
   if(g_mode == MYSQL)
     cout<<"BEGIN;"<<endl;