From: Rosen Penev Date: Thu, 5 Nov 2020 08:08:42 +0000 (-0800) Subject: clang-tidy: use nullptr X-Git-Tag: dnsdist-1.6.0-alpha2~55^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4646277d05f293777a3d2423a3b188ccdf42c6bc;p=thirdparty%2Fpdns.git clang-tidy: use nullptr Found with modernize-use-nullptr Signed-off-by: Rosen Penev --- diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 0cd049a13e..0cd68a26c1 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -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 *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&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]"; diff --git a/modules/gmysqlbackend/smysql.cc b/modules/gmysqlbackend/smysql.cc index 501c4432c6..b889970ec7 100644 --- a/modules/gmysqlbackend/smysql.cc +++ b/modules/gmysqlbackend/smysql.cc @@ -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;igr_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 &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")) { diff --git a/pdns/auth-carbon.cc b/pdns/auth-carbon.cc index 3f839d2b6b..8fa3e1596a 100644 --- a/pdns/auth-carbon.cc +++ b/pdns/auth-carbon.cc @@ -62,7 +62,7 @@ try string msg; vector entries = S.getEntries(); ostringstream str; - time_t now=time(0); + time_t now=time(nullptr); for(const string& entry : entries) { str<id); d_trc.d_eRcode=0; diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 776dd55a25..8c204b0ec2 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -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; } diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 06cce20f3f..db4b4aa5dc 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -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) diff --git a/pdns/communicator.cc b/pdns/communicator.cc index a1ba12a406..2bbf969db6 100644 --- a/pdns/communicator.cc +++ b/pdns/communicator.cc @@ -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) { diff --git a/pdns/dbdnsseckeeper.cc b/pdns/dbdnsseckeeper.cc index 0373d5bb3a..ed1724d5d0 100644 --- a/pdns/dbdnsseckeeper.cc +++ b/pdns/dbdnsseckeeper.cc @@ -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)) { { diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index ecb8e98d0d..834378586f 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -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++; diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index 37cf92653e..147daafb32 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -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; diff --git a/pdns/dnsproxy.cc b/pdns/dnsproxy.cc index 0f03334830..6fb166b113 100644 --- a/pdns/dnsproxy.cc +++ b/pdns/dnsproxy.cc @@ -138,7 +138,7 @@ bool DNSProxy::completePacket(std::unique_ptr& 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.createdsecond.createdsecond.created) { g_log<second.remote.toStringWithPort()<<" with internal id "<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); diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index d7a79abf33..2a668c3b32 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -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() diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index d57a13ae6f..97d88499e3 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -347,7 +347,7 @@ std::unique_ptr 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(key.c_str()), key.size(), reinterpret_cast(text.c_str()), text.size(), hash, &outlen); - if (out == NULL || outlen == 0) { + if (out == nullptr || outlen == 0) { throw PDNSException("HMAC computation failed"); } diff --git a/pdns/dnssecsigner.cc b/pdns/dnssecsigner.cc index 88ebcf4d56..27a12a3f40 100644 --- a/pdns/dnssecsigner.cc +++ b/pdns/dnssecsigner.cc @@ -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); diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index f655d68362..8926738f56 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -124,7 +124,7 @@ string DLStatusHandler(const vector&parts, Utility::pid_t ppid) string DLUptimeHandler(const vector&parts, Utility::pid_t ppid) { ostringstream os; - os<&parts, Utility::pid_t ppid) string DLSettingsHandler(const vector&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) { diff --git a/pdns/ednsoptions.cc b/pdns/ednsoptions.cc index 97acca8040..ebda4d2dbb 100644 --- a/pdns/ednsoptions.cc +++ b/pdns/ednsoptions.cc @@ -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; diff --git a/pdns/iputils.cc b/pdns/iputils.cc index b8eb5e9219..019eff2dd2 100644 --- a/pdns/iputils.cc +++ b/pdns/iputils.cc @@ -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(msgh), const_cast(cmsg))) { + for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != nullptr; cmsg = CMSG_NXTHDR(const_cast(msgh), const_cast(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); } diff --git a/pdns/ixfr.cc b/pdns/ixfr.cc index bafead50e1..dfda4d3f50 100644 --- a/pdns/ixfr.cc +++ b/pdns/ixfr.cc @@ -146,7 +146,7 @@ vector, vector > > 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; diff --git a/pdns/lua-auth4.cc b/pdns/lua-auth4.cc index 90c527626f..aa5bcf09bb 100644 --- a/pdns/lua-auth4.cc +++ b/pdns/lua-auth4.cc @@ -88,16 +88,16 @@ void AuthLua4::postPrepareContext() { } void AuthLua4::postLoad() { - d_update_policy = d_lw->readVariable>("updatepolicy").get_value_or(0); - d_axfr_filter = d_lw->readVariable>("axfrfilter").get_value_or(0); - d_prequery = d_lw->readVariable>("prequery").get_value_or(0); + d_update_policy = d_lw->readVariable>("updatepolicy").get_value_or(nullptr); + d_axfr_filter = d_lw->readVariable>("axfrfilter").get_value_or(nullptr); + d_prequery = d_lw->readVariable>("prequery").get_value_or(nullptr); } bool AuthLua4::axfrfilter(const ComboAddress& remote, const DNSName& zone, const DNSResourceRecord& in, vector& 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); diff --git a/pdns/mastercommunicator.cc b/pdns/mastercommunicator.cc index 0b50ec1102..624a2e65d3 100644 --- a/pdns/mastercommunicator.cc +++ b/pdns/mastercommunicator.cc @@ -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 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 diff --git a/pdns/misc.cc b/pdns/misc.cc index 3babc59234..de9e003eb9 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -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 { diff --git a/pdns/nameserver.cc b/pdns/nameserver.cc index 5dff5148a4..8a7310a9ae 100644 --- a/pdns/nameserver.cc +++ b/pdns/nameserver.cc @@ -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); } diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 0a99163253..773b90a84f 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -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 PacketHandler::doQuestion(DNSPacket& p) g_log< PacketHandler::doQuestion(DNSPacket& p) g_log< 0) { @@ -1276,7 +1276,7 @@ std::unique_ptr PacketHandler::doQuestion(DNSPacket& p) r->setOpcode(Opcode::Notify); return r; } - return 0; + return nullptr; } g_log< 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 PacketHandler::doQuestion(DNSPacket& p) if(!haveAlias.empty() && (!weDone || p.qtype.getCode() == QType::ANY)) { DLOG(g_log<completePacket(r, haveAlias, target, aliasScopeMask); - return 0; + return nullptr; } diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index f093827c2e..17b5639c83 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -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* suppliedrecords=0) +static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vector* 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; diff --git a/pdns/rcpgenerator.cc b/pdns/rcpgenerator.cc index fe9830b363..b1d849aeae 100644 --- a/pdns/rcpgenerator.cc +++ b/pdns/rcpgenerator.cc @@ -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); diff --git a/pdns/receiver.cc b/pdns/receiver.cc index c68c192925..4ee8584894 100644 --- a/pdns/receiver.cc +++ b/pdns/receiver.cc @@ -231,7 +231,7 @@ static int guardian(int argc, char **argv) g_log<d_update_policy_lua == NULL) { + if (this->d_update_policy_lua == nullptr) { // Check permissions - IP based vector 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<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<d_name << "/" << QType(rr->d_type).getName() << ": Not permitted by policy"<(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 "< doAxfr(const ComboAddress& raddr, const DNSName { uint16_t axfr_timeout=::arg().asNum("axfr-fetch-timeout"); vector 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 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 l(d_lock); domains_by_name_t& nameindex=boost::multi_index::get(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<= 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) { diff --git a/pdns/tkey.cc b/pdns/tkey.cc index 7e0c76e91b..d8bb30b17d 100644 --- a/pdns/tkey.cc +++ b/pdns/tkey.cc @@ -18,7 +18,7 @@ void PacketHandler::tkeyHandler(const DNSPacket& p, std::unique_ptr& 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 diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index 4df720760c..13ad058140 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -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< client) const { g_log<"; ret<<"
"; - time_t passed=time(0)-s_starttime; + time_t passed=time(nullptr)-s_starttime; ret<<"

Uptime: "<< humanDuration(passed)<< @@ -496,7 +496,7 @@ void productServerStatisticsFetch(map& out) } // add uptime - out["uptime"] = std::to_string(time(0) - s_starttime); + out["uptime"] = std::to_string(time(nullptr) - s_starttime); } boost::optional 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"); diff --git a/pdns/zone2sql.cc b/pdns/zone2sql.cc index d52e5f38a7..339b7ffecb 100644 --- a/pdns/zone2sql.cc +++ b/pdns/zone2sql.cc @@ -111,7 +111,7 @@ static void startNewTransaction() cout<<"BEGIN TRANSACTION;"< *masters = 0) { +static void emitDomain(const DNSName& domain, const vector *masters = nullptr) { string iDomain = domain.toStringRootDot(); if(!::arg().mustDo("slave")) { cout<<"insert into domains (name,type) values ("< *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="<