]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
clang-tidy: use nullptr
authorRosen Penev <rosenp@gmail.com>
Thu, 5 Nov 2020 08:08:42 +0000 (00:08 -0800)
committerRosen Penev <rosenp@gmail.com>
Fri, 5 Feb 2021 01:22:41 +0000 (17:22 -0800)
Found with modernize-use-nullptr

Signed-off-by: Rosen Penev <rosenp@gmail.com>
41 files changed:
modules/bindbackend/bindbackend2.cc
modules/gmysqlbackend/smysql.cc
modules/pipebackend/pipebackend.cc
pdns/arguments.cc
pdns/auth-carbon.cc
pdns/axfr-retriever.cc
pdns/backends/gsql/gsqlbackend.cc
pdns/common_startup.cc
pdns/communicator.cc
pdns/dbdnsseckeeper.cc
pdns/dnsname.cc
pdns/dnsparser.cc
pdns/dnsproxy.cc
pdns/dnsrecords.cc
pdns/dnssecinfra.cc
pdns/dnssecsigner.cc
pdns/dynhandler.cc
pdns/ednsoptions.cc
pdns/iputils.cc
pdns/ixfr.cc
pdns/lua-auth4.cc
pdns/mastercommunicator.cc
pdns/misc.cc
pdns/nameserver.cc
pdns/packethandler.cc
pdns/pdnsutil.cc
pdns/rcpgenerator.cc
pdns/receiver.cc
pdns/resolver.cc
pdns/rfc2136handler.cc
pdns/secpoll-auth.cc
pdns/serialtweaker.cc
pdns/slavecommunicator.cc
pdns/statbag.cc
pdns/tcpreceiver.cc
pdns/tkey.cc
pdns/ueberbackend.cc
pdns/unix_utility.cc
pdns/webserver.cc
pdns/ws-auth.cc
pdns/zone2sql.cc

index 0cd049a13e691203fca5839ea706b94868072244..0cd68a26c14795eca7b03f84c844efefc1d645ec 100644 (file)
@@ -106,7 +106,7 @@ bool BB2DomainInfo::current()
   if(!d_checkinterval) 
     return true;
 
-  if(time(0) - d_lastcheck < d_checkinterval) 
+  if(time(nullptr) - d_lastcheck < d_checkinterval) 
     return true;
   
   if(d_filename.empty())
@@ -121,7 +121,7 @@ time_t BB2DomainInfo::getCtime()
   
   if(d_filename.empty() || stat(d_filename.c_str(),&buf)<0)
     return 0; 
-  d_lastcheck=time(0);
+  d_lastcheck=time(nullptr);
   return buf.st_ctime;
 }
 
@@ -188,7 +188,7 @@ void Bind2Backend::setFresh(uint32_t domain_id)
 {
   BB2DomainInfo bbd;
   if(safeGetBBDomainInfo(domain_id, &bbd)) {
-    bbd.d_lastcheck=time(0);
+    bbd.d_lastcheck=time(nullptr);
     safePutBBDomainInfo(bbd);
   }
 }
@@ -417,7 +417,7 @@ void Bind2Backend::getUnfreshSlaveInfos(vector<DomainInfo> *unfreshDomains)
     }
     catch(...){}
     sd.serial=soadata.serial;
-    if(sd.last_check+soadata.refresh < (unsigned int)time(0))
+    if(sd.last_check+soadata.refresh < (unsigned int)time(nullptr))
       unfreshDomains->push_back(std::move(sd));
   }
 }
@@ -705,20 +705,20 @@ string Bind2Backend::DLAddDomainHandler(const vector<string>&parts, Utility::pid
 
 Bind2Backend::Bind2Backend(const string &suffix, bool loadZones)
 {
-  d_getAllDomainMetadataQuery_stmt = NULL;
-  d_getDomainMetadataQuery_stmt = NULL;
-  d_deleteDomainMetadataQuery_stmt = NULL;
-  d_insertDomainMetadataQuery_stmt = NULL;
-  d_getDomainKeysQuery_stmt = NULL;
-  d_deleteDomainKeyQuery_stmt = NULL;
-  d_insertDomainKeyQuery_stmt = NULL;
-  d_GetLastInsertedKeyIdQuery_stmt = NULL;
-  d_activateDomainKeyQuery_stmt = NULL;
-  d_deactivateDomainKeyQuery_stmt = NULL;
-  d_getTSIGKeyQuery_stmt = NULL;
-  d_setTSIGKeyQuery_stmt = NULL;
-  d_deleteTSIGKeyQuery_stmt = NULL;
-  d_getTSIGKeysQuery_stmt = NULL;
+  d_getAllDomainMetadataQuery_stmt = nullptr;
+  d_getDomainMetadataQuery_stmt = nullptr;
+  d_deleteDomainMetadataQuery_stmt = nullptr;
+  d_insertDomainMetadataQuery_stmt = nullptr;
+  d_getDomainKeysQuery_stmt = nullptr;
+  d_deleteDomainKeyQuery_stmt = nullptr;
+  d_insertDomainKeyQuery_stmt = nullptr;
+  d_GetLastInsertedKeyIdQuery_stmt = nullptr;
+  d_activateDomainKeyQuery_stmt = nullptr;
+  d_deactivateDomainKeyQuery_stmt = nullptr;
+  d_getTSIGKeyQuery_stmt = nullptr;
+  d_setTSIGKeyQuery_stmt = nullptr;
+  d_deleteTSIGKeyQuery_stmt = nullptr;
+  d_getTSIGKeysQuery_stmt = nullptr;
 
   setArgPrefix("bind"+suffix);
   d_logprefix="[bind"+suffix+"backend]";
index 501c4432c6c4e5e3ae6e70f5c44dbf11d4c75e2d..b889970ec727e64fb80801e6fbe6248971803cda 100644 (file)
@@ -77,8 +77,8 @@ public:
     d_query = query;
     d_paridx = d_fnum = d_resnum = d_residx = 0;
     d_parnum = nparams;
-    d_req_bind = d_res_bind = NULL;
-    d_stmt = NULL;
+    d_req_bind = d_res_bind = nullptr;
+    d_stmt = nullptr;
 
     if (query.empty()) {
       return;
@@ -374,7 +374,7 @@ private:
       return;
     }
 
-    if ((d_stmt = mysql_stmt_init(d_db))==NULL)
+    if ((d_stmt = mysql_stmt_init(d_db))==nullptr)
       throw SSqlException("Could not initialize mysql statement, out of memory: " + d_query);
 
     if (mysql_stmt_prepare(d_stmt, d_query.c_str(), d_query.size()) != 0) {
@@ -400,14 +400,14 @@ private:
     d_prepared = false;
     if (d_stmt)
       mysql_stmt_close(d_stmt);
-    d_stmt = NULL;
+    d_stmt = nullptr;
     if (d_req_bind) {
       for(int i=0;i<d_parnum;i++) {
         if (d_req_bind[i].buffer) delete [] (char*)d_req_bind[i].buffer;
         if (d_req_bind[i].length) delete [] d_req_bind[i].length;
       }
       delete [] d_req_bind;
-      d_req_bind = NULL;
+      d_req_bind = nullptr;
     }
     if (d_res_bind) {
       for(int i=0;i<d_fnum;i++) {
@@ -417,7 +417,7 @@ private:
         if (d_res_bind[i].is_null) delete [] d_res_bind[i].is_null;
       }
       delete [] d_res_bind;
-      d_res_bind = NULL;
+      d_res_bind = nullptr;
     }
     d_paridx = d_fnum = d_resnum = d_residx = 0;
   }
@@ -470,12 +470,12 @@ void SMySQL::connect()
 
     mysql_options(&d_db, MYSQL_READ_DEFAULT_GROUP, d_group.c_str());
 
-    if (!mysql_real_connect(&d_db, d_host.empty() ? NULL : d_host.c_str(),
-                            d_user.empty() ? NULL : d_user.c_str(),
-                            d_password.empty() ? NULL : d_password.c_str(),
-                            d_database.empty() ? NULL : d_database.c_str(),
+    if (!mysql_real_connect(&d_db, d_host.empty() ? nullptr : d_host.c_str(),
+                            d_user.empty() ? nullptr : d_user.c_str(),
+                            d_password.empty() ? nullptr : d_password.c_str(),
+                            d_database.empty() ? nullptr : d_database.c_str(),
                             d_port,
-                            d_msocket.empty() ? NULL : d_msocket.c_str(),
+                            d_msocket.empty() ? nullptr : d_msocket.c_str(),
                             (d_clientSSL ? CLIENT_SSL : 0) | CLIENT_MULTI_RESULTS)) {
 
       if (retry == 0)
index c8e9a77c2b12fb5d7895ca3190b54f0fa3a836e4..c24d8ce113e57069ebd17d053f1afbe7ccf609e2 100644 (file)
@@ -148,7 +148,7 @@ void PipeBackend::launch()
  */
 void PipeBackend::cleanup()
 {
-  d_coproc.reset(0);
+  d_coproc.reset(nullptr);
   d_regex.reset();
   d_regexstr = string();
   d_abiVersion = 0;
@@ -253,7 +253,7 @@ DNSBackend *PipeBackend::maker()
    }
    catch(...) {
       g_log<<Logger::Error<<kBackendId<<" Unable to instantiate a pipebackend!"<<endl;
-      return 0;
+      return nullptr;
    }
 }
 
index 12a71aebd74341abfedca0e6a36a8f4fa1073210..6cc6e801b3e0535152a93d9188578d609e33a66d 100644 (file)
@@ -212,7 +212,7 @@ mode_t ArgvMap::asMode(const string &arg)
 {
   mode_t mode;
   const char *cptr_orig;
-  char *cptr_ret = NULL;
+  char *cptr_ret = nullptr;
 
   if(!parmIsset(arg))
    throw ArgException(string("Undefined but needed argument: '")+arg+"'");
@@ -228,7 +228,7 @@ gid_t ArgvMap::asGid(const string &arg)
 {
   gid_t gid;
   const char *cptr_orig;
-  char *cptr_ret = NULL;
+  char *cptr_ret = nullptr;
 
   if(!parmIsset(arg))
    throw ArgException(string("Undefined but needed argument: '")+arg+"'");
@@ -238,7 +238,7 @@ gid_t ArgvMap::asGid(const string &arg)
   if (gid == 0 && cptr_ret == cptr_orig) {
     // try to resolve
     struct group *group = getgrnam(params[arg].c_str());
-    if (group == NULL)
+    if (group == nullptr)
      throw ArgException("'" + arg + string("' contains invalid group"));
     gid = group->gr_gid;
    }
@@ -249,7 +249,7 @@ uid_t ArgvMap::asUid(const string &arg)
 {
   uid_t uid;
   const char *cptr_orig;
-  char *cptr_ret = NULL;
+  char *cptr_ret = nullptr;
 
   if(!parmIsset(arg))
    throw ArgException(string("Undefined but needed argument: '")+arg+"'");
@@ -259,7 +259,7 @@ uid_t ArgvMap::asUid(const string &arg)
   if (uid == 0 && cptr_ret == cptr_orig) {
     // try to resolve
     struct passwd *pwent = getpwnam(params[arg].c_str());
-    if (pwent == NULL)
+    if (pwent == nullptr)
      throw ArgException("'" + arg + string("' contains invalid group"));
     uid = pwent->pw_uid;
    }
@@ -270,7 +270,7 @@ int ArgvMap::asNum(const string &arg, int def)
 {
   int retval;
   const char *cptr_orig;
-  char *cptr_ret = NULL;
+  char *cptr_ret = nullptr;
 
   if(!parmIsset(arg))
     throw ArgException(string("Undefined but needed argument: '")+arg+"'");
@@ -298,7 +298,7 @@ double ArgvMap::asDouble(const string &arg)
 {
   double retval;
   const char *cptr_orig;
-  char *cptr_ret = NULL;
+  char *cptr_ret = nullptr;
 
   if(!parmIsset(arg))
     throw ArgException(string("Undefined but needed argument: '")+arg+"'");
@@ -503,7 +503,7 @@ void ArgvMap::gatherIncludes(std::vector<std::string> &extraConfigs) {
   }
 
   struct dirent *ent;
-  while ((ent = readdir(dir)) != NULL) {
+  while ((ent = readdir(dir)) != nullptr) {
     if (ent->d_name[0] == '.')
       continue; // skip any dots
     if (boost::ends_with(ent->d_name, ".conf")) {
index 3f839d2b6bd2a7c907264de4291b7b4c11b83635..8fa3e1596a1ed28cbcd20459b7a55c3c45424f4d 100644 (file)
@@ -62,7 +62,7 @@ try
     string msg;
     vector<string> entries = S.getEntries();
     ostringstream str;
-    time_t now=time(0);
+    time_t now=time(nullptr);
     for(const string& entry : entries) {
       str<<namespace_name<<'.'<<hostname<<'.'<<instance_name<<'.'<<entry<<' '<<S.read(entry)<<' '<<now<<"\r\n";
     }
index 457f66f0bf2ad76cd8f9e5b8cac0104bff48b4dd..99f386bc148bec366f8653a95c14bbb253d53f5a 100644 (file)
@@ -65,7 +65,7 @@ AXFRRetriever::AXFRRetriever(const ComboAddress& remote,
         d_trc.d_algoName = tt.algo + DNSName("sig-alg.reg.int");
       else
         d_trc.d_algoName = tt.algo;
-      d_trc.d_time = time(0);
+      d_trc.d_time = time(nullptr);
       d_trc.d_fudge = 300;
       d_trc.d_origID=ntohs(pw.getHeader()->id);
       d_trc.d_eRcode=0;
index 776dd55a25fba1da266630521f2a252199bded56..8c204b0ec2dfccf6e5892fa44d302ac1b8d714a6 100644 (file)
@@ -129,66 +129,66 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix)
   d_SearchRecordsQuery = getArg("search-records-query");
   d_SearchCommentsQuery = getArg("search-comments-query");
 
-  d_query_stmt = NULL;
-  d_NoIdQuery_stmt = NULL;
-  d_IdQuery_stmt = NULL;
-  d_ANYNoIdQuery_stmt = NULL;
-  d_ANYIdQuery_stmt = NULL;
-  d_listQuery_stmt = NULL;
-  d_listSubZoneQuery_stmt = NULL;
-  d_InfoOfDomainsZoneQuery_stmt = NULL;
-  d_InfoOfAllSlaveDomainsQuery_stmt = NULL;
-  d_SuperMasterInfoQuery_stmt = NULL;
-  d_GetSuperMasterIPs_stmt = NULL;
-  d_AddSuperMaster_stmt = NULL;
-  d_InsertZoneQuery_stmt = NULL;
-  d_InsertRecordQuery_stmt = NULL;
-  d_InsertEmptyNonTerminalOrderQuery_stmt = NULL;
-  d_UpdateMasterOfZoneQuery_stmt = NULL;
-  d_UpdateKindOfZoneQuery_stmt = NULL;
-  d_UpdateSerialOfZoneQuery_stmt = NULL;
-  d_UpdateLastCheckofZoneQuery_stmt = NULL;
-  d_UpdateAccountOfZoneQuery_stmt = NULL;
-  d_InfoOfAllMasterDomainsQuery_stmt = NULL;
-  d_DeleteDomainQuery_stmt = NULL;
-  d_DeleteZoneQuery_stmt = NULL;
-  d_DeleteRRSetQuery_stmt = NULL;
-  d_DeleteNamesQuery_stmt = NULL;
-  d_firstOrderQuery_stmt = NULL;
-  d_beforeOrderQuery_stmt = NULL;
-  d_afterOrderQuery_stmt = NULL;
-  d_lastOrderQuery_stmt = NULL;
-  d_updateOrderNameAndAuthQuery_stmt = NULL;
-  d_updateOrderNameAndAuthTypeQuery_stmt = NULL;
-  d_nullifyOrderNameAndUpdateAuthQuery_stmt = NULL;
-  d_nullifyOrderNameAndUpdateAuthTypeQuery_stmt = NULL;
-  d_RemoveEmptyNonTerminalsFromZoneQuery_stmt = NULL;
-  d_DeleteEmptyNonTerminalQuery_stmt = NULL;
-  d_AddDomainKeyQuery_stmt = NULL;
-  d_GetLastInsertedKeyIdQuery_stmt = NULL;
-  d_ListDomainKeysQuery_stmt = NULL;
-  d_GetAllDomainMetadataQuery_stmt = NULL;
-  d_GetDomainMetadataQuery_stmt = NULL;
-  d_ClearDomainMetadataQuery_stmt = NULL;
-  d_ClearDomainAllMetadataQuery_stmt = NULL;
-  d_SetDomainMetadataQuery_stmt = NULL;
-  d_RemoveDomainKeyQuery_stmt = NULL;
-  d_ActivateDomainKeyQuery_stmt = NULL;
-  d_DeactivateDomainKeyQuery_stmt = NULL;
-  d_PublishDomainKeyQuery_stmt = NULL;
-  d_UnpublishDomainKeyQuery_stmt = NULL;
-  d_ClearDomainAllKeysQuery_stmt = NULL;
-  d_getTSIGKeyQuery_stmt = NULL;
-  d_setTSIGKeyQuery_stmt = NULL;
-  d_deleteTSIGKeyQuery_stmt = NULL;
-  d_getTSIGKeysQuery_stmt = NULL;
-  d_getAllDomainsQuery_stmt = NULL;
-  d_ListCommentsQuery_stmt = NULL;
-  d_InsertCommentQuery_stmt = NULL;
-  d_DeleteCommentRRsetQuery_stmt = NULL;
-  d_DeleteCommentsQuery_stmt = NULL;
-  d_SearchRecordsQuery_stmt = NULL;
-  d_SearchCommentsQuery_stmt = NULL;
+  d_query_stmt = nullptr;
+  d_NoIdQuery_stmt = nullptr;
+  d_IdQuery_stmt = nullptr;
+  d_ANYNoIdQuery_stmt = nullptr;
+  d_ANYIdQuery_stmt = nullptr;
+  d_listQuery_stmt = nullptr;
+  d_listSubZoneQuery_stmt = nullptr;
+  d_InfoOfDomainsZoneQuery_stmt = nullptr;
+  d_InfoOfAllSlaveDomainsQuery_stmt = nullptr;
+  d_SuperMasterInfoQuery_stmt = nullptr;
+  d_GetSuperMasterIPs_stmt = nullptr;
+  d_AddSuperMaster_stmt = nullptr;
+  d_InsertZoneQuery_stmt = nullptr;
+  d_InsertRecordQuery_stmt = nullptr;
+  d_InsertEmptyNonTerminalOrderQuery_stmt = nullptr;
+  d_UpdateMasterOfZoneQuery_stmt = nullptr;
+  d_UpdateKindOfZoneQuery_stmt = nullptr;
+  d_UpdateSerialOfZoneQuery_stmt = nullptr;
+  d_UpdateLastCheckofZoneQuery_stmt = nullptr;
+  d_UpdateAccountOfZoneQuery_stmt = nullptr;
+  d_InfoOfAllMasterDomainsQuery_stmt = nullptr;
+  d_DeleteDomainQuery_stmt = nullptr;
+  d_DeleteZoneQuery_stmt = nullptr;
+  d_DeleteRRSetQuery_stmt = nullptr;
+  d_DeleteNamesQuery_stmt = nullptr;
+  d_firstOrderQuery_stmt = nullptr;
+  d_beforeOrderQuery_stmt = nullptr;
+  d_afterOrderQuery_stmt = nullptr;
+  d_lastOrderQuery_stmt = nullptr;
+  d_updateOrderNameAndAuthQuery_stmt = nullptr;
+  d_updateOrderNameAndAuthTypeQuery_stmt = nullptr;
+  d_nullifyOrderNameAndUpdateAuthQuery_stmt = nullptr;
+  d_nullifyOrderNameAndUpdateAuthTypeQuery_stmt = nullptr;
+  d_RemoveEmptyNonTerminalsFromZoneQuery_stmt = nullptr;
+  d_DeleteEmptyNonTerminalQuery_stmt = nullptr;
+  d_AddDomainKeyQuery_stmt = nullptr;
+  d_GetLastInsertedKeyIdQuery_stmt = nullptr;
+  d_ListDomainKeysQuery_stmt = nullptr;
+  d_GetAllDomainMetadataQuery_stmt = nullptr;
+  d_GetDomainMetadataQuery_stmt = nullptr;
+  d_ClearDomainMetadataQuery_stmt = nullptr;
+  d_ClearDomainAllMetadataQuery_stmt = nullptr;
+  d_SetDomainMetadataQuery_stmt = nullptr;
+  d_RemoveDomainKeyQuery_stmt = nullptr;
+  d_ActivateDomainKeyQuery_stmt = nullptr;
+  d_DeactivateDomainKeyQuery_stmt = nullptr;
+  d_PublishDomainKeyQuery_stmt = nullptr;
+  d_UnpublishDomainKeyQuery_stmt = nullptr;
+  d_ClearDomainAllKeysQuery_stmt = nullptr;
+  d_getTSIGKeyQuery_stmt = nullptr;
+  d_setTSIGKeyQuery_stmt = nullptr;
+  d_deleteTSIGKeyQuery_stmt = nullptr;
+  d_getTSIGKeysQuery_stmt = nullptr;
+  d_getAllDomainsQuery_stmt = nullptr;
+  d_ListCommentsQuery_stmt = nullptr;
+  d_InsertCommentQuery_stmt = nullptr;
+  d_DeleteCommentRRsetQuery_stmt = nullptr;
+  d_DeleteCommentsQuery_stmt = nullptr;
+  d_SearchRecordsQuery_stmt = nullptr;
+  d_SearchCommentsQuery_stmt = nullptr;
 }
 
 void GSQLBackend::setNotified(uint32_t domain_id, uint32_t serial)
@@ -213,7 +213,7 @@ void GSQLBackend::setFresh(uint32_t domain_id)
     reconnectIfNeeded();
 
     d_UpdateLastCheckofZoneQuery_stmt->
-      bind("last_check", time(0))->
+      bind("last_check", time(nullptr))->
       bind("domain_id", domain_id)->
       execute()->
       reset();
@@ -1216,7 +1216,7 @@ skiprow:
   } catch (SSqlException &e) {
       throw PDNSException("GSQLBackend get: "+e.txtReason());
   }
-  d_query_stmt = NULL;
+  d_query_stmt = nullptr;
   return false;
 }
 
@@ -1675,7 +1675,7 @@ bool GSQLBackend::getComment(Comment& comment)
       } catch(SSqlException &e) {
         throw PDNSException("GSQLBackend comment get: "+e.txtReason());
       }
-      d_query_stmt = NULL;
+      d_query_stmt = nullptr;
       return false;
     }
 
index 06cce20f3f4ad17fd46a52e45d8488bfb48cfa86..db4b4aa5dcbf7c6104286c8bf9ba379a94391d58 100644 (file)
@@ -247,10 +247,10 @@ void declareArguments()
   ::arg().setDefaults();
 }
 
-static time_t s_start=time(0);
+static time_t s_start=time(nullptr);
 static uint64_t uptimeOfProcess(const std::string& str)
 {
-  return time(0) - s_start;
+  return time(nullptr) - s_start;
 }
 
 static uint64_t getSysUserTimeMsec(const std::string& str)
index a1ba12a4060f21578463a8eef12cdb52b1704a1c..2bbf969db62f1d4cfc10159917aad62728342a25 100644 (file)
@@ -127,9 +127,9 @@ void CommunicatorClass::mainloop()
       
       tick = min (tick, d_tickinterval); 
       
-      next=time(0)+tick;
+      next=time(nullptr)+tick;
 
-      while(time(0) < next) {
+      while(time(nullptr) < next) {
         rc=d_any_sem.tryWait();
 
         if(rc) {
index 0373d5bb3a5042d1e65bd3832bb69dddd8184926..ed1724d5d0c29c6c06efe0f378eb244ef865b848 100644 (file)
@@ -545,7 +545,7 @@ DNSSECKeeper::keyset_t DNSSECKeeper::getEntryPoints(const DNSName& zname)
 DNSSECKeeper::keyset_t DNSSECKeeper::getKeys(const DNSName& zone, bool useCache)
 {
   static int ttl = ::arg().asNum("dnssec-key-cache-ttl");
-  unsigned int now = time(0);
+  unsigned int now = time(nullptr);
 
   if(!((++s_ops) % 100000)) {
     cleanup();
@@ -937,7 +937,7 @@ bool DNSSECKeeper::rectifyZone(const DNSName& zone, string& error, string& info,
 void DNSSECKeeper::cleanup()
 {
   struct timeval now;
-  Utility::gettimeofday(&now, 0);
+  Utility::gettimeofday(&now, nullptr);
 
   if(now.tv_sec - s_last_prune > (time_t)(30)) {
     {
index ecb8e98d0ddaf321410b6554b3f8ee87cbba56d5..834378586f82cb70a8e137518c721b4abad68c1e 100644 (file)
@@ -126,7 +126,7 @@ void DNSName::packetParser(const char* qpos, int len, int offset, bool uncompres
           throw std::range_error("Invalid label position during decompression ("+std::to_string(newpos)+ " < "+std::to_string(minOffset)+")");
         if (++depth > 100)
           throw std::range_error("Abort label decompression after 100 redirects");
-        packetParser((const char*)opos, len, newpos, true, 0, 0, 0, depth, minOffset);
+        packetParser((const char*)opos, len, newpos, true, nullptr, nullptr, nullptr, depth, minOffset);
       } else
         throw std::range_error("Found a forward reference during label decompression");
       pos++;
index 37cf92653e45c99b8fcc4e398b281c6695801135..147daafb325c281cf9ca4b83e27b917ca3fc5556 100644 (file)
@@ -431,7 +431,7 @@ DNSName PacketReader::getName()
 {
   unsigned int consumed;
   try {
-    DNSName dn((const char*) d_content.data(), d_content.size(), d_pos, true /* uncompress */, 0 /* qtype */, 0 /* qclass */, &consumed, sizeof(dnsheader));
+    DNSName dn((const char*) d_content.data(), d_content.size(), d_pos, true /* uncompress */, nullptr /* qtype */, nullptr /* qclass */, &consumed, sizeof(dnsheader));
     
     d_pos+=consumed;
     return dn;
index 0f03334830c05072fd207413f3a7376c6d3a1f5f..6fb166b113f86c23b30c9fc77646f03690b5907c 100644 (file)
@@ -138,7 +138,7 @@ bool DNSProxy::completePacket(std::unique_ptr<DNSPacket>& r, const DNSName& targ
     ce.id       = r->d.id;
     ce.remote =   r->d_remote;
     ce.outsock  = r->getSocket();
-    ce.created  = time( NULL );
+    ce.created  = time( nullptr );
     ce.qtype = r->qtype.getCode();
     ce.qname = target;
     ce.anyLocal = r->d_anyLocal;
@@ -171,7 +171,7 @@ int DNSProxy::getID_locked()
     if(i==d_conntrack.end()) {
       return n;
     }
-    else if(i->second.created<time(0)-60) {
+    else if(i->second.created<time(nullptr)-60) {
       if(i->second.created) {
         g_log<<Logger::Warning<<"Recursive query for remote "<<
           i->second.remote.toStringWithPort()<<" with internal id "<<n<<
@@ -282,7 +282,7 @@ void DNSProxy::mainloop()
         msgh.msg_iovlen = 1;
         msgh.msg_name = (struct sockaddr*)&i->second.remote;
         msgh.msg_namelen = i->second.remote.getSocklen();
-        msgh.msg_control=NULL;
+        msgh.msg_control=nullptr;
 
         if(i->second.anyLocal) {
           addCMsgSrcAddr(&msgh, &cbuf, i->second.anyLocal.get_ptr(), 0);
index d7a79abf33922e350f7b87fc72a690250fd17ed8..2a668c3b32edba652c7e4bb0b8dc9b3914cdd1d1 100644 (file)
@@ -831,9 +831,9 @@ void reportBasicTypes()
 #ifdef HAVE_LUA_RECORDS
   LUARecordContent::report();
 #endif
-  DNSRecordContent::regist(QClass::IN, QType::ANY, 0, 0, "ANY");
-  DNSRecordContent::regist(QClass::IN, QType::AXFR, 0, 0, "AXFR");
-  DNSRecordContent::regist(QClass::IN, QType::IXFR, 0, 0, "IXFR");
+  DNSRecordContent::regist(QClass::IN, QType::ANY, nullptr, nullptr, "ANY");
+  DNSRecordContent::regist(QClass::IN, QType::AXFR, nullptr, nullptr, "AXFR");
+  DNSRecordContent::regist(QClass::IN, QType::IXFR, nullptr, nullptr, "IXFR");
 }
 
 void reportOtherTypes()
index d57a13ae6f0c950ae771eb5a1a423de18df109b6..97d88499e35d43f58bc1405858bf00eeb8e03853 100644 (file)
@@ -347,7 +347,7 @@ std::unique_ptr<DNSCryptoKeyEngine> DNSCryptoKeyEngine::makeFromPEMString(DNSKEY
     {
     }
   }
-  return 0;
+  return nullptr;
 }
 
 /**
@@ -479,7 +479,7 @@ static DNSKEYRecordContent makeDNSKEYFromDNSCryptoKeyEngine(const std::shared_pt
 
 uint32_t getStartOfWeek()
 {
-  uint32_t now = time(0);
+  uint32_t now = time(nullptr);
   now -= (now % (7*86400));
   return now;
 }
@@ -588,7 +588,7 @@ static string calculateHMAC(const std::string& key, const std::string& text, TSI
   }
 
   unsigned char* out = HMAC(md_type, reinterpret_cast<const unsigned char*>(key.c_str()), key.size(), reinterpret_cast<const unsigned char*>(text.c_str()), text.size(), hash, &outlen);
-  if (out == NULL || outlen == 0) {
+  if (out == nullptr || outlen == 0) {
     throw PDNSException("HMAC computation failed");
   }
 
index 88ebcf4d56c910e9941272307f588f18d09a883f..27a12a3f402aa7f262e1ce5cb69d87a46845d4a2 100644 (file)
@@ -80,7 +80,7 @@ static void fillOutRRSIG(DNSSECPrivateKey& dpk, const DNSName& signQName, RRSIGR
   (*g_signatureCount)++;
   if(doCache) {
     /* we add some jitter here so not all your slaves start pruning their caches at the very same millisecond */
-    int weekno = (time(0) - dns_random(3600)) / (86400*7);  // we just spent milliseconds doing a signature, microsecond more won't kill us
+    int weekno = (time(nullptr) - dns_random(3600)) / (86400*7);  // we just spent milliseconds doing a signature, microsecond more won't kill us
     const static int maxcachesize=::arg().asNum("max-signature-cache-entries", INT_MAX);
 
     WriteLock l(&g_signatures_lock);
index f655d6836263559a806e98431ced0f42baac220e..8926738f5673cc9612c9d3eb046bbb2be10d31f3 100644 (file)
@@ -124,7 +124,7 @@ string DLStatusHandler(const vector<string>&parts, Utility::pid_t ppid)
 string DLUptimeHandler(const vector<string>&parts, Utility::pid_t ppid)
 {
   ostringstream os;
-  os<<humanDuration(time(0)-s_starttime);
+  os<<humanDuration(time(nullptr)-s_starttime);
   return os.str();
 }
 
@@ -212,7 +212,7 @@ string DLRemotesHandler(const vector<string>&parts, Utility::pid_t ppid)
 
 string DLSettingsHandler(const vector<string>&parts, Utility::pid_t ppid)
 {
-  static const char *whitelist[]={"query-logging",0};
+  static const char *whitelist[]={"query-logging",nullptr};
   const char **p;
 
   if(parts.size()!=3) {
index 97acca80401f77d194df5987a6964bc10b9db6de..ebda4d2dbb189dcbd30cb8f2694c5ceb2a58c4f0 100644 (file)
@@ -94,7 +94,7 @@ int getEDNSOption(const char* optRR, const size_t len, uint16_t wantedOption, si
 /* extract all EDNS0 options from a pointer on the beginning rdLen of the OPT RR */
 int getEDNSOptions(const char* optRR, const size_t len, EDNSOptionViewMap& options)
 {
-  assert(optRR != NULL);
+  assert(optRR != nullptr);
   size_t pos = 0;
   if (len < DNS_RDLENGTH_SIZE)
     return EINVAL;
index b8eb5e9219fe7c5c5aa34b161ea0f6df48a13c0f..019eff2dd2d40e33521268f5dcf60a0459527bb1 100644 (file)
@@ -184,7 +184,7 @@ bool HarvestTimestamp(struct msghdr* msgh, struct timeval* tv)
 {
 #ifdef SO_TIMESTAMP
   struct cmsghdr *cmsg;
-  for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(msgh,cmsg)) {
+  for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != nullptr; cmsg = CMSG_NXTHDR(msgh,cmsg)) {
     if ((cmsg->cmsg_level == SOL_SOCKET) && (cmsg->cmsg_type == SO_TIMESTAMP || cmsg->cmsg_type == SCM_TIMESTAMP) && 
        CMSG_LEN(sizeof(*tv)) == cmsg->cmsg_len) {
       memcpy(tv, CMSG_DATA(cmsg), sizeof(*tv));
@@ -202,7 +202,7 @@ bool HarvestDestinationAddress(const struct msghdr* msgh, ComboAddress* destinat
 #else
   const struct cmsghdr* cmsg;
 #endif
-  for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(const_cast<struct msghdr*>(msgh), const_cast<struct cmsghdr*>(cmsg))) {
+  for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != nullptr; cmsg = CMSG_NXTHDR(const_cast<struct msghdr*>(msgh), const_cast<struct cmsghdr*>(cmsg))) {
 #if defined(IP_PKTINFO)
      if ((cmsg->cmsg_level == IPPROTO_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
         struct in_pktinfo *i = (struct in_pktinfo *) CMSG_DATA(cmsg);
@@ -280,7 +280,7 @@ ssize_t sendfromto(int sock, const void* data, size_t len, int flags, const Comb
     addCMsgSrcAddr(&msgh, &cbuf, &from, 0);
   }
   else {
-    msgh.msg_control=NULL;
+    msgh.msg_control=nullptr;
   }
   return sendmsg(sock, &msgh, flags);
 }
index bafead50e1ca9ecc66d5d095161ef747ec55d78f..dfda4d3f50f38632ec9a9697b712527323c94ef6 100644 (file)
@@ -146,7 +146,7 @@ vector<pair<vector<DNSRecord>, vector<DNSRecord> > > getIXFRDeltas(const ComboAd
     } catch(PDNSException& pe) {
       throw std::runtime_error("TSIG algorithm '"+tt.algo.toLogString()+"' is unknown.");
     }
-    trc.d_time = time((time_t*)NULL);
+    trc.d_time = time((time_t*)nullptr);
     trc.d_fudge = 300;
     trc.d_origID=ntohs(pw.getHeader()->id);
     trc.d_eRcode=0;
index 90c527626f0892c10c59a58e2a80e4bf7576b467..aa5bcf09bbf12fcfbd3cf941015db7b94aba92ef 100644 (file)
@@ -88,16 +88,16 @@ void AuthLua4::postPrepareContext() {
 }
 
 void AuthLua4::postLoad() {
-  d_update_policy = d_lw->readVariable<boost::optional<luacall_update_policy_t>>("updatepolicy").get_value_or(0);
-  d_axfr_filter = d_lw->readVariable<boost::optional<luacall_axfr_filter_t>>("axfrfilter").get_value_or(0);
-  d_prequery = d_lw->readVariable<boost::optional<luacall_prequery_t>>("prequery").get_value_or(0);
+  d_update_policy = d_lw->readVariable<boost::optional<luacall_update_policy_t>>("updatepolicy").get_value_or(nullptr);
+  d_axfr_filter = d_lw->readVariable<boost::optional<luacall_axfr_filter_t>>("axfrfilter").get_value_or(nullptr);
+  d_prequery = d_lw->readVariable<boost::optional<luacall_prequery_t>>("prequery").get_value_or(nullptr);
 }
 
 bool AuthLua4::axfrfilter(const ComboAddress& remote, const DNSName& zone, const DNSResourceRecord& in, vector<DNSResourceRecord>& out) {
   luacall_axfr_filter_t::result_type ret;
   int rcode;
 
-  if (d_axfr_filter == NULL) return false;
+  if (d_axfr_filter == nullptr) return false;
 
   ret = d_axfr_filter(remote, zone, in);
   rcode = std::get<0>(ret);
index 0b50ec11028ff75713a34fbec6b1d38040077053..624a2e65d3b0a95fa7c6283a9e4d6bcbf064c92d 100644 (file)
@@ -263,7 +263,7 @@ void CommunicatorClass::sendNotification(int sock, const DNSName& domain, const
       trc.d_algoName = DNSName(tsigalgorithm.toStringNoDot() + ".sig-alg.reg.int.");
     else
       trc.d_algoName = tsigalgorithm;
-    trc.d_time = time(0);
+    trc.d_time = time(nullptr);
     trc.d_fudge = 300;
     trc.d_origID=ntohs(id);
     trc.d_eRcode=0;
@@ -282,7 +282,7 @@ void CommunicatorClass::sendNotification(int sock, const DNSName& domain, const
 void CommunicatorClass::drillHole(const DNSName &domain, const string &ip)
 {
   std::lock_guard<std::mutex> l(d_holelock);
-  d_holes[make_pair(domain,ip)]=time(0);
+  d_holes[make_pair(domain,ip)]=time(nullptr);
 }
 
 bool CommunicatorClass::justNotified(const DNSName &domain, const string &ip)
@@ -291,7 +291,7 @@ bool CommunicatorClass::justNotified(const DNSName &domain, const string &ip)
   if(d_holes.find(make_pair(domain,ip))==d_holes.end()) // no hole
     return false;
 
-  if(d_holes[make_pair(domain,ip)]>time(0)-900)    // recent hole
+  if(d_holes[make_pair(domain,ip)]>time(nullptr)-900)    // recent hole
     return true;
 
   // do we want to purge this? XXX FIXME 
index 3babc592344499b03dc9ab3631bc70afd00c9753..de9e003eb9b725a2714be5cdd6f5e94dbe742219 100644 (file)
@@ -116,7 +116,7 @@ size_t readn2WithTimeout(int fd, void* buffer, size_t len, int idleTimeout, int
   time_t start = 0;
   int remainingTime = totalTimeout;
   if (totalTimeout) {
-    start = time(NULL);
+    start = time(nullptr);
   }
 
   do {
@@ -145,7 +145,7 @@ size_t readn2WithTimeout(int fd, void* buffer, size_t len, int idleTimeout, int
     }
 
     if (totalTimeout) {
-      time_t now = time(NULL);
+      time_t now = time(nullptr);
       int elapsed = now - start;
       if (elapsed >= remainingTime) {
         throw runtime_error("Timeout while reading data");
@@ -688,7 +688,7 @@ int makeIPv6sockaddr(const std::string& addr, struct sockaddr_in6* ret)
     hints.ai_flags = AI_NUMERICHOST;
 
     // getaddrinfo has anomalous return codes, anything nonzero is an error, positive or negative
-    if (getaddrinfo(ourAddr.c_str(), 0, &hints, &res) != 0) {
+    if (getaddrinfo(ourAddr.c_str(), nullptr, &hints, &res) != 0) {
       return -1;
     }
 
@@ -793,7 +793,7 @@ Regex::Regex(const string &expr)
 // Note that cmsgbuf should be aligned the same as a struct cmsghdr
 void addCMsgSrcAddr(struct msghdr* msgh, cmsgbuf_aligned* cmsgbuf, const ComboAddress* source, int itfIndex)
 {
-  struct cmsghdr *cmsg = NULL;
+  struct cmsghdr *cmsg = nullptr;
 
   if(source->sin4.sin_family == AF_INET6) {
     struct in6_pktinfo *pkt;
@@ -1344,7 +1344,7 @@ uid_t strToUID(const string &str)
   const char * cstr = str.c_str();
   struct passwd * pwd = getpwnam(cstr);
 
-  if (pwd == NULL) {
+  if (pwd == nullptr) {
     long long val;
 
     try {
@@ -1373,7 +1373,7 @@ gid_t strToGID(const string &str)
   const char * cstr = str.c_str();
   struct group * grp = getgrnam(cstr);
 
-  if (grp == NULL) {
+  if (grp == nullptr) {
     long long val;
 
     try {
index 5dff5148a446555e08e7865b95b3cc4bf76a263e..8a7310a9aeae31380469b6470b6a6830a66ccc9f 100644 (file)
@@ -229,7 +229,7 @@ void UDPNameserver::send(DNSPacket& p)
 
   fillMSGHdr(&msgh, &iov, &cbuf, 0, (char*)buffer.c_str(), buffer.length(), &p.d_remote);
 
-  msgh.msg_control=NULL;
+  msgh.msg_control=nullptr;
   if(p.d_anyLocal) {
     addCMsgSrcAddr(&msgh, &cbuf, p.d_anyLocal.get_ptr(), 0);
   }
index 0a991632539b5c2582707bebce2761fa4a94c7a9..773b90a84fdd5e075ee39ffde601d6904894e071 100644 (file)
@@ -71,7 +71,7 @@ PacketHandler::PacketHandler():B(s_programname), d_dk(&B)
   string fname= ::arg()["lua-prequery-script"];
   if(fname.empty())
   {
-    d_pdl = NULL;
+    d_pdl = nullptr;
   }
   else
   {
@@ -81,7 +81,7 @@ PacketHandler::PacketHandler():B(s_programname), d_dk(&B)
   fname = ::arg()["lua-dnsupdate-policy-script"];
   if (fname.empty())
   {
-    d_update_policy_lua = NULL;
+    d_update_policy_lua = nullptr;
   }
   else
   {
@@ -1196,7 +1196,7 @@ std::unique_ptr<DNSPacket> PacketHandler::doQuestion(DNSPacket& p)
       g_log<<Logger::Error<<"Received an answer (non-query) packet from "<<p.getRemote()<<", dropping"<<endl;
     S.inc("corrupt-packets");
     S.ringAccount("remotes-corrupt", p.d_remote);
-    return 0;
+    return nullptr;
   }
 
   if(p.d.tc) { // truncated query. MOADNSParser would silently parse this packet in an incomplete way.
@@ -1204,7 +1204,7 @@ std::unique_ptr<DNSPacket> PacketHandler::doQuestion(DNSPacket& p)
       g_log<<Logger::Error<<"Received truncated query packet from "<<p.getRemote()<<", dropping"<<endl;
     S.inc("corrupt-packets");
     S.ringAccount("remotes-corrupt", p.d_remote);
-    return 0;
+    return nullptr;
   }
 
   if (p.hasEDNS() && p.getEDNSVersion() > 0) {
@@ -1276,7 +1276,7 @@ std::unique_ptr<DNSPacket> PacketHandler::doQuestion(DNSPacket& p)
           r->setOpcode(Opcode::Notify);
           return r;
         }
-        return 0;
+        return nullptr;
       }
       
       g_log<<Logger::Error<<"Received an unknown opcode "<<p.d.opcode<<" from "<<p.getRemote()<<" for "<<p.qdomain<<endl;
@@ -1376,7 +1376,7 @@ std::unique_ptr<DNSPacket> PacketHandler::doQuestion(DNSPacket& p)
     }
 
     // this TRUMPS a cname!
-    if(d_dnssec && p.qtype.getCode() == QType::NSEC && !d_dk.getNSEC3PARAM(d_sd.qname, 0)) {
+    if(d_dnssec && p.qtype.getCode() == QType::NSEC && !d_dk.getNSEC3PARAM(d_sd.qname, nullptr)) {
       addNSEC(p, r, target, DNSName(), 5);
       if (!r->isEmpty())
         goto sendit;
@@ -1496,7 +1496,7 @@ std::unique_ptr<DNSPacket> PacketHandler::doQuestion(DNSPacket& p)
     if(!haveAlias.empty() && (!weDone || p.qtype.getCode() == QType::ANY)) {
       DLOG(g_log<<Logger::Warning<<"Found nothing that matched for '"<<target<<"', but did get alias to '"<<haveAlias<<"', referring"<<endl);
       DP->completePacket(r, haveAlias, target, aliasScopeMask);
-      return 0;
+      return nullptr;
     }
 
 
index f093827c2ecb2addda7c65062f83368e6e5ff72c..17b5639c835033a042fe07f4dc5464f1105b6c1d 100644 (file)
@@ -238,7 +238,7 @@ static bool rectifyAllZones(DNSSECKeeper &dk, bool quiet = false)
   return result;
 }
 
-static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vector<DNSResourceRecord>* suppliedrecords=0)
+static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vector<DNSResourceRecord>* suppliedrecords=nullptr)
 {
   uint64_t numerrors=0, numwarnings=0;
 
@@ -3471,7 +3471,7 @@ try
     }
 
     DNSBackend *src,*tgt;
-    src = tgt = NULL;
+    src = tgt = nullptr;
 
     for(DNSBackend *b : BackendMakers().all()) {
       if (b->getPrefix() == cmds[1]) src = b;
@@ -3571,7 +3571,7 @@ try
     }
 
     DNSBackend *db;
-    db = NULL;
+    db = nullptr;
 
     for(DNSBackend *b : BackendMakers().all()) {
       if (b->getPrefix() == cmds[1]) db = b;
index fe9830b36345d4dc127cb1d71b51d9ec9200edca..b1d849aeaea6d83f6fc46543e9e5d953332814ab 100644 (file)
@@ -629,7 +629,7 @@ void RecordTextWriter::xfrIP6(const std::string& val)
   
   val.copy(tmpbuf,16);
 
-  if (inet_ntop(AF_INET6, tmpbuf, addrbuf, sizeof addrbuf) == NULL)
+  if (inet_ntop(AF_INET6, tmpbuf, addrbuf, sizeof addrbuf) == nullptr)
     throw RecordTextException("Unable to convert to ipv6 address");
   
   d_string += std::string(addrbuf);
index c68c192925468711f6045c3ef4a881864ca10e37..4ee85848947472218b6dd7e335b99a90d6f95bc5 100644 (file)
@@ -231,7 +231,7 @@ static int guardian(int argc, char **argv)
       g_log<<Logger::Critical<<"Unable to associate a file pointer with pipe: "<<stringerror()<<endl;
       exit(1);
     }
-    setbuf(g_fp,0); // no buffering please, confuses select
+    setbuf(g_fp,nullptr); // no buffering please, confuses select
 
     if(!(pid=fork())) { // child
       signal(SIGTERM, SIG_DFL);
@@ -252,7 +252,7 @@ static int guardian(int argc, char **argv)
       for(n=1;n<argc;n++) {
         newargv[n]=argv[n];
       }
-      newargv[n]=0;
+      newargv[n]=nullptr;
       
       g_log<<Logger::Error<<"Guardian is launching an instance"<<endl;
       close(g_fd1[1]);
@@ -317,7 +317,7 @@ static int guardian(int argc, char **argv)
       g_guardian_lock.lock();
       close(g_fd1[1]);
       fclose(g_fp);
-      g_fp=0;
+      g_fp=nullptr;
 
       if(WIFEXITED(status)) {
         int ret=WEXITSTATUS(status);
@@ -384,7 +384,7 @@ int main(int argc, char **argv)
   reportAllTypes(); // init MOADNSParser
 
   s_programname="pdns";
-  s_starttime=time(0);
+  s_starttime=time(nullptr);
 
 #if defined(__GLIBC__) && !defined(__UCLIBC__)
   signal(SIGSEGV,tbhandler);
index 2d07e1e8557f02092ab926e63abac7f1125a5a70..1f569c4d1885479fa16b6dbabd031a0a9db55c6f 100644 (file)
@@ -147,7 +147,7 @@ uint16_t Resolver::sendResolve(const ComboAddress& remote, const ComboAddress& l
       trc.d_algoName = tsigalgorithm + DNSName("sig-alg.reg.int");
     else
       trc.d_algoName = tsigalgorithm;
-    trc.d_time = time(0);
+    trc.d_time = time(nullptr);
     trc.d_fudge = 300;
     trc.d_origID=ntohs(randomid);
     trc.d_eRcode=0;
index e9acd77b7d254830e851e4a930c9b47292dfb1a6..35d52e5903517be164055fbf1f9e6b6a3f468a8e 100644 (file)
@@ -648,7 +648,7 @@ int PacketHandler::processUpdate(DNSPacket& p) {
   g_log<<Logger::Info<<msgPrefix<<"Processing started."<<endl;
 
   // if there is policy, we delegate all checks to it
-  if (this->d_update_policy_lua == NULL) {
+  if (this->d_update_policy_lua == nullptr) {
 
     // Check permissions - IP based
     vector<string> allowedRanges;
@@ -719,7 +719,7 @@ int PacketHandler::processUpdate(DNSPacket& p) {
   }
 
   DomainInfo di;
-  di.backend=0;
+  di.backend=nullptr;
   if(!B.getDomainInfo(p.qdomain, di) || !di.backend) {
     g_log<<Logger::Error<<msgPrefix<<"Can't determine backend for domain '"<<p.qdomain<<"' (or backend does not support DNS update operation)"<<endl;
     return RCode::NotAuth;
@@ -866,7 +866,7 @@ int PacketHandler::processUpdate(DNSPacket& p) {
       const DNSRecord *rr = &d_answer.first;
       if (rr->d_place == DNSResourceRecord::AUTHORITY) {
         /* see if it's permitted by policy */
-        if (this->d_update_policy_lua != NULL) {
+        if (this->d_update_policy_lua != nullptr) {
           if (this->d_update_policy_lua->updatePolicy(rr->d_name, QType(rr->d_type), di.zone, p) == false) {
             g_log<<Logger::Warning<<msgPrefix<<"Refusing update for " << rr->d_name << "/" << QType(rr->d_type).getName() << ": Not permitted by policy"<<endl;
             continue;
index 435051a136da4649e871bab2ceda85b2851c3935..7cc132aada7a39d7b4f046d677d22002a46b5dc7 100644 (file)
@@ -35,7 +35,7 @@ void doSecPoll(bool first)
     return;
 
   struct timeval now;
-  gettimeofday(&now, 0);
+  gettimeofday(&now, nullptr);
   string pkgv(PACKAGEVERSION);
 
   string version = "auth-" + pkgv;
index 1409c8d68d14161f0f107e9972652dfbdb8e9ec8..3b85ae055b43abf2e915f1e761c90bf5aeb9d1ae 100644 (file)
@@ -59,7 +59,7 @@ uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const DNSName
     return (old_serial + (inception / (7*86400)));
   }
   else if(pdns_iequals(kind,"EPOCH")) {
-    return time(0);
+    return time(nullptr);
   }
   else if(pdns_iequals(kind,"INCEPTION-EPOCH")) {
     uint32_t inception = getStartOfWeek();
@@ -107,10 +107,10 @@ static uint32_t calculateIncreaseSOA(uint32_t old_serial, const string& increase
     return old_serial + 1;
   }
   else if (pdns_iequals(increaseKind, "EPOCH")) {
-    return time(0);
+    return time(nullptr);
   }
   else if (pdns_iequals(increaseKind, "DEFAULT")) {
-    time_t now = time(0);
+    time_t now = time(nullptr);
     uint32_t new_serial = localtime_format_YYYYMMDDSS(now, 1);
     if (new_serial <= old_serial) {
         new_serial = old_serial + 1;
index 747b2962c0210f35b1fb796233164579a94d0665..e7d6692bbc4de01989fd23b459948d29841b7014 100644 (file)
@@ -88,7 +88,7 @@ void CommunicatorClass::ixfrSuck(const DNSName &domain, const TSIGTriplet& tt, c
   UeberBackend B; // fresh UeberBackend
 
   DomainInfo di;
-  di.backend=0;
+  di.backend=nullptr;
   //  bool transaction=false;
   try {
     DNSSECKeeper dk (&B); // reuse our UeberBackend copy for DNSSECKeeper
@@ -109,7 +109,7 @@ void CommunicatorClass::ixfrSuck(const DNSName &domain, const TSIGTriplet& tt, c
 
     DNSRecord drsoa;
     drsoa.d_content = std::make_shared<SOARecordContent>(g_rootdnsname, g_rootdnsname, st);
-    auto deltas = getIXFRDeltas(remote, domain, drsoa, tt, laddr.sin4.sin_family ? &laddr : 0, ((size_t) ::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024);
+    auto deltas = getIXFRDeltas(remote, domain, drsoa, tt, laddr.sin4.sin_family ? &laddr : nullptr, ((size_t) ::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024);
     zs.numDeltas=deltas.size();
     //    cout<<"Got "<<deltas.size()<<" deltas from serial "<<di.serial<<", applying.."<<endl;
     
@@ -245,7 +245,7 @@ static vector<DNSResourceRecord> doAxfr(const ComboAddress& raddr, const DNSName
 {
   uint16_t axfr_timeout=::arg().asNum("axfr-fetch-timeout");
   vector<DNSResourceRecord> rrs;
-  AXFRRetriever retriever(raddr, domain, tt, (laddr.sin4.sin_family == 0) ? NULL : &laddr, ((size_t) ::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024, axfr_timeout);
+  AXFRRetriever retriever(raddr, domain, tt, (laddr.sin4.sin_family == 0) ? nullptr : &laddr, ((size_t) ::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024, axfr_timeout);
   Resolver::res_t recs;
   bool first=true;
   bool firstNSEC3{true};
@@ -314,7 +314,7 @@ void CommunicatorClass::suck(const DNSName &domain, const ComboAddress& remote,
   UeberBackend B; // fresh UeberBackend
 
   DomainInfo di;
-  di.backend=0;
+  di.backend=nullptr;
   bool transaction=false;
   try {
     DNSSECKeeper dk (&B); // reuse our UeberBackend copy for DNSSECKeeper
@@ -647,7 +647,7 @@ void CommunicatorClass::suck(const DNSName &domain, const ComboAddress& remote,
       // still succeed, we would constantly try to AXFR the zone. To avoid this, we add the zone to the list of
       // failed slave-checks. This will suspend slave-checks (and subsequent AXFR) for this zone for some time.
       uint64_t newCount = 1;
-      time_t now = time(0);
+      time_t now = time(nullptr);
       const auto failedEntry = d_failedSlaveRefresh.find(domain);
       if (failedEntry != d_failedSlaveRefresh.end())
         newCount = d_failedSlaveRefresh[domain].first + 1;
@@ -736,7 +736,7 @@ void CommunicatorClass::addSlaveCheckRequest(const DomainInfo& di, const ComboAd
 {
   std::lock_guard<std::mutex> l(d_lock);
   DomainInfo ours = di;
-  ours.backend = 0;
+  ours.backend = nullptr;
 
   // When adding a check, if the remote addr from which notification was
   // received is a master, clear all other masters so we can be sure the
@@ -813,7 +813,7 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P)
   {
     std::lock_guard<std::mutex> l(d_lock);
     domains_by_name_t& nameindex=boost::multi_index::get<IDTag>(d_suckdomains);
-    time_t now = time(0);
+    time_t now = time(nullptr);
 
     for(DomainInfo& di :  rdomains) {
       const auto failed = d_failedSlaveRefresh.find(di.zone);
@@ -910,7 +910,7 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P)
     g_log<<Logger::Info<<"Received serial number updates for "<<ssr.d_freshness.size()<<" zone"<<addS(ssr.d_freshness.size())<<endl;
   }
 
-  time_t now = time(0);
+  time_t now = time(nullptr);
   for(auto& val : sdomains) {
     DomainInfo& di(val.di);
     // If our di comes from packethandler (caused by incoming NOTIFY), di.backend will not be filled out,
index b4d406e5e665bba15380a61758a13b2935ee0572..a04e81c78c10e08759c0d7c7edef7c2035498da1 100644 (file)
@@ -156,7 +156,7 @@ unsigned long StatBag::readZero(const string &key)
 {
   exists(key);
   unsigned long tmp=*d_stats[key];
-  d_stats[key]=0;
+  d_stats[key]=nullptr;
   return tmp;
 }
 
index e140107980fb135246928594a77283097f387baf..ebc7505b9f445e81ade55103f856219babbc333d 100644 (file)
@@ -101,7 +101,7 @@ static int readnWithTimeout(int fd, void* buffer, unsigned int n, unsigned int i
   time_t start = 0;
   unsigned int remainingTotal = totalTimeout;
   if (totalTimeout) {
-    start = time(NULL);
+    start = time(nullptr);
   }
   while(bytes) {
     ret=read(fd, ptr, bytes);
@@ -127,7 +127,7 @@ static int readnWithTimeout(int fd, void* buffer, unsigned int n, unsigned int i
     ptr += ret;
     bytes -= ret;
     if (totalTimeout) {
-      time_t now = time(NULL);
+      time_t now = time(nullptr);
       unsigned int elapsed = now - start;
       if (elapsed >= remainingTotal) {
         throw NetworkError("Timeout while reading data");
@@ -200,7 +200,7 @@ static void incTCPAnswerCount(const ComboAddress& remote)
 static bool maxConnectionDurationReached(unsigned int maxConnectionDuration, time_t start, unsigned int& remainingTime)
 {
   if (maxConnectionDuration) {
-    time_t elapsed = time(NULL) - start;
+    time_t elapsed = time(nullptr) - start;
     if (elapsed >= maxConnectionDuration) {
       return true;
     }
@@ -229,7 +229,7 @@ void TCPNameserver::doConnection(int fd)
   size_t transactions = 0;
   time_t start = 0;
   if (d_maxConnectionDuration) {
-    start = time(NULL);
+    start = time(nullptr);
   }
 
   if(getpeername(fd, (struct sockaddr *)&remote, &remotelen) < 0) {
index 7e0c76e91ba4912c8550866cbede4730a25deea1..d8bb30b17d67f6d2beab8df539334f7ef30dca9c 100644 (file)
@@ -18,7 +18,7 @@ void PacketHandler::tkeyHandler(const DNSPacket& p, std::unique_ptr<DNSPacket>&
   tkey_out->d_error = 0;
   tkey_out->d_mode = tkey_in.d_mode;
   tkey_out->d_algo = tkey_in.d_algo;
-  tkey_out->d_inception = time((time_t*)NULL);
+  tkey_out->d_inception = time((time_t*)nullptr);
   tkey_out->d_expiration = tkey_out->d_inception+15;
 
   if (tkey_in.d_mode == 3) { // establish context
index 4df720760c43e4d754a467dc35a656ce49e5759e..13ad0581400bcf87c9bcf1567db6846b3a9eea85 100644 (file)
@@ -66,7 +66,7 @@ bool UeberBackend::loadmodule(const string &name)
 
   void *dlib=dlopen(name.c_str(), RTLD_NOW);
 
-  if(dlib == NULL) {
+  if(dlib == nullptr) {
     g_log<<Logger::Error <<"Unable to load module '"<<name<<"': "<<dlerror() << endl;
     return false;
   }
@@ -692,9 +692,9 @@ UeberBackend::handle::handle()
 {
   //  g_log<<Logger::Warning<<"Handle instances: "<<instances<<endl;
   ++instances;
-  parent=NULL;
-  d_hinterBackend=NULL;
-  pkt_p=NULL;
+  parent=nullptr;
+  d_hinterBackend=nullptr;
+  pkt_p=nullptr;
   i=0;
   zoneId = -1;
 }
index a3992b5e7f64ab0a53d84f20f6ed0e8abd453c33..8d209275d2e3f3ee3322db5e990914c25d102d17 100644 (file)
@@ -69,7 +69,7 @@ int Utility::timed_connect( Utility::sock_t sock,
       return ret;
   }
 
-  ret = select(sock + 1, NULL, &set, NULL, &timeout);
+  ret = select(sock + 1, nullptr, &set, nullptr, &timeout);
   setBlocking(sock);
 
   return ret;
@@ -119,7 +119,7 @@ void Utility::usleep(unsigned long usec)
   ts.tv_sec = usec / 1000000;
   ts.tv_nsec = (usec % 1000000) * 1000;
   // POSIX.1 recommends using nanosleep instead of usleep
-  ::nanosleep(&ts, NULL); 
+  ::nanosleep(&ts, nullptr); 
 }
 
 
@@ -137,7 +137,7 @@ void Utility::dropGroupPrivs( uid_t uid, gid_t gid )
     struct passwd *pw=getpwuid(uid);
     if(!pw) {
       g_log<<Logger::Warning<<"Unable to determine user name for uid "<<uid<<endl;
-      if (setgroups(0, NULL)<0) {
+      if (setgroups(0, nullptr)<0) {
         g_log<<Logger::Critical<<"Unable to drop supplementary gids: "<<stringerror()<<endl;
         exit(1);
       }
@@ -175,14 +175,14 @@ Utility::pid_t Utility::getpid( )
 // Returns the current time.
 int Utility::gettimeofday( struct timeval *tv, void *tz )
 {
-  return ::gettimeofday(tv,0);
+  return ::gettimeofday(tv,nullptr);
 }
 
 // Sets the random seed.
 void Utility::srandom()
 {
   struct timeval tv;
-  gettimeofday(&tv, 0);
+  gettimeofday(&tv, nullptr);
   ::srandom(tv.tv_sec ^ tv.tv_usec ^ getpid());
 }
 
index 252506da0f99af8e12af3841b5c765c3003631a8..91e5487b82366575d6815030b7d8b7a4be6040c0 100644 (file)
@@ -436,7 +436,7 @@ void WebServer::serveConnection(std::shared_ptr<Socket> client) const {
     g_log<<Logger::Error<<logprefix<<"HTTP Exception: "<<e.reason<<endl;
   }
   catch(std::exception &e) {
-    if(strstr(e.what(), "timeout")==0)
+    if(strstr(e.what(), "timeout")==nullptr)
       g_log<<Logger::Error<<logprefix<<"HTTP STL Exception: "<<e.what()<<endl;
   }
   catch(...) {
index 9a43f04480221739139d38082facbd9400ea6ef4..52f78bdaed67d0e38262531b210bd347dc043ea5 100644 (file)
@@ -235,7 +235,7 @@ void AuthWebServer::indexfunction(HttpRequest* req, HttpResponse* resp)
   ret<<"<div class=\"headr columns\"></div></div>";
   ret<<"<div class=\"row\"><div class=\"all columns\">";
 
-  time_t passed=time(0)-s_starttime;
+  time_t passed=time(nullptr)-s_starttime;
 
   ret<<"<p>Uptime: "<<
     humanDuration(passed)<<
@@ -496,7 +496,7 @@ void productServerStatisticsFetch(map<string,string>& out)
   }
 
   // add uptime
-  out["uptime"] = std::to_string(time(0) - s_starttime);
+  out["uptime"] = std::to_string(time(nullptr) - s_starttime);
 }
 
 boost::optional<uint64_t> productServerStatisticsFetch(const std::string& name)
@@ -561,7 +561,7 @@ static void gatherComments(const Json container, const DNSName& qname, const QTy
   c.qname = qname;
   c.qtype = qtype;
 
-  time_t now = time(0);
+  time_t now = time(nullptr);
   for (auto comment : container["comments"].array_items()) {
     c.modified_at = intFromJson(comment, "modified_at", now);
     c.content = stringFromJson(comment, "content");
index d52e5f38a7291c58dd98a85f87fa770910d9f4b9..339b7ffecb1ff7d6f85621595a46f695dc464019 100644 (file)
@@ -111,7 +111,7 @@ static void startNewTransaction()
     cout<<"BEGIN TRANSACTION;"<<endl;
 }
 
-static void emitDomain(const DNSName& domain, const vector<ComboAddress> *masters = 0) {
+static void emitDomain(const DNSName& domain, const vector<ComboAddress> *masters = nullptr) {
   string iDomain = domain.toStringRootDot();
   if(!::arg().mustDo("slave")) {
     cout<<"insert into domains (name,type) values ("<<toLower(sqlstr(iDomain))<<",'NATIVE');"<<endl;
@@ -119,7 +119,7 @@ static void emitDomain(const DNSName& domain, const vector<ComboAddress> *master
   else
   {
     string mstrs;
-    if (masters != 0 && ! masters->empty()) {
+    if (masters != nullptr && ! masters->empty()) {
       for(const auto& mstr :  *masters) {
         mstrs.append(mstr.toStringWithPortExcept(53));
         mstrs.append(1, ' ');
@@ -177,7 +177,7 @@ static void emitRecord(const DNSName& zoneName, const DNSName &DNSqname, const s
     " from domains where name="<<toLower(sqlstr(zname))<<";\n";
 
   if(!recordcomment.empty()) {
-    cout<<"insert into comments (domain_id,name,type,modified_at, comment) select id, "<<toLower(sqlstr(stripDot(qname)))<<", "<<sqlstr(qtype)<<", "<<time(0)<<", "<<sqlstr(recordcomment)<<" from domains where name="<<toLower(sqlstr(zname))<<";\n";
+    cout<<"insert into comments (domain_id,name,type,modified_at, comment) select id, "<<toLower(sqlstr(stripDot(qname)))<<", "<<sqlstr(qtype)<<", "<<time(nullptr)<<", "<<sqlstr(recordcomment)<<" from domains where name="<<toLower(sqlstr(zname))<<";\n";
   }
 }