From: Otto Moerbeek Date: Tue, 3 Nov 2020 13:55:25 +0000 (+0100) Subject: Include less in namespaces.hh and use more std::; X-Git-Tag: dnsdist-1.6.0-alpha0~7^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc5930463ae0b12b549324f76a019bbaa92e6322;p=thirdparty%2Fpdns.git Include less in namespaces.hh and use more std::; boost stuff now needs explicit scoping. --- diff --git a/modules/pipebackend/coprocess.cc b/modules/pipebackend/coprocess.cc index 52ca5f95a3..3065684f99 100644 --- a/modules/pipebackend/coprocess.cc +++ b/modules/pipebackend/coprocess.cc @@ -42,7 +42,7 @@ CoProcess::CoProcess(const string &command,int timeout, int infd, int outfd): d_infd(infd), d_outfd(outfd), d_timeout(timeout) { - split(d_params, command, is_any_of(" ")); + split(d_params, command, boost::is_any_of(" ")); d_argv.resize(d_params.size()+1); d_argv[d_params.size()]=nullptr; @@ -206,7 +206,7 @@ void CoProcess::receive(string &received) } received.resize(eolPos); - trim_right(received); + boost::trim_right(received); } void CoProcess::sendReceive(const string &snd, string &rcv) @@ -246,7 +246,7 @@ void UnixRemote::receive(string& line) { line.clear(); stringfgets(d_fp.get(), line); - trim_right(line); + boost::trim_right(line); } void UnixRemote::sendReceive(const string &snd, string &rcv) diff --git a/modules/remotebackend/pipeconnector.cc b/modules/remotebackend/pipeconnector.cc index d30ed06e63..e9d116b60d 100644 --- a/modules/remotebackend/pipeconnector.cc +++ b/modules/remotebackend/pipeconnector.cc @@ -61,7 +61,7 @@ void PipeConnector::launch() { if (d_pid > 0 && checkStatus()) return; std::vector v; - split(v, command, is_any_of(" ")); + split(v, command, boost::is_any_of(" ")); std::vectorargv(v.size()+1); argv[v.size()]=0; diff --git a/pdns/arguments.cc b/pdns/arguments.cc index 2c1ad26574..12a71aebd7 100644 --- a/pdns/arguments.cc +++ b/pdns/arguments.cc @@ -418,7 +418,7 @@ bool ArgvMap::parseFile(const char *fname, const string& arg, bool lax) { return false; while(getline(f,pline)) { - trim_right(pline); + boost::trim_right(pline); if(!pline.empty() && pline[pline.size()-1]=='\\') { line+=pline.substr(0,pline.length()-1); @@ -436,7 +436,7 @@ bool ArgvMap::parseFile(const char *fname, const string& arg, bool lax) { } // strip trailing spaces - trim_right(line); + boost::trim_right(line); // strip leading spaces if((pos=line.find_first_not_of(" \t\r\n"))!=string::npos) diff --git a/pdns/auth-packetcache.cc b/pdns/auth-packetcache.cc index 4ed8112fbd..e31a0182ef 100644 --- a/pdns/auth-packetcache.cc +++ b/pdns/auth-packetcache.cc @@ -234,7 +234,7 @@ uint64_t AuthPacketCache::purge(const string &match) uint64_t delcount = 0; - if(ends_with(match, "$")) { + if(boost::ends_with(match, "$")) { delcount = purgeLockedCollectionsVector(d_maps, match); *d_statnumentries -= delcount; } diff --git a/pdns/auth-querycache.cc b/pdns/auth-querycache.cc index 82489e1e92..623f09e5c4 100644 --- a/pdns/auth-querycache.cc +++ b/pdns/auth-querycache.cc @@ -194,7 +194,7 @@ uint64_t AuthQueryCache::purge(const string &match) { uint64_t delcount = 0; - if(ends_with(match, "$")) { + if(boost::ends_with(match, "$")) { delcount = purgeLockedCollectionsVector(d_maps, match); *d_statnumentries -= delcount; } diff --git a/pdns/axfr-retriever.cc b/pdns/axfr-retriever.cc index 4d2718efd3..457f66f0bf 100644 --- a/pdns/axfr-retriever.cc +++ b/pdns/axfr-retriever.cc @@ -51,7 +51,7 @@ AXFRRetriever::AXFRRetriever(const ComboAddress& remote, d_sock = makeQuerySocket(local, false); // make a TCP socket if (d_sock < 0) throw ResolverException("Error creating socket for AXFR request to "+d_remote.toStringWithPort()); - d_buf = shared_array(new char[65536]); + d_buf = boost::shared_array(new char[65536]); d_remote = remote; // mostly for error reporting this->connect(timeout); d_soacount = 0; diff --git a/pdns/axfr-retriever.hh b/pdns/axfr-retriever.hh index 6c1aba8ab3..f3e5c2bb88 100644 --- a/pdns/axfr-retriever.hh +++ b/pdns/axfr-retriever.hh @@ -21,6 +21,7 @@ */ #pragma once #include +#include #include "iputils.hh" #include "dnsname.hh" @@ -43,7 +44,7 @@ class AXFRRetriever : public boost::noncopyable int getLength(uint16_t timeout); void timeoutReadn(uint16_t bytes, uint16_t timeoutsec=10); - shared_array d_buf; + boost::shared_array d_buf; string d_domain; int d_sock; int d_soacount; diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 5d545f753f..bcb351769b 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -1501,7 +1501,7 @@ bool GSQLBackend::feedRecord(const DNSResourceRecord &r, const DNSName &ordernam prio=pdns_stou(content.substr(0,pos)); boost::erase_head(content, pos); } - trim_left(content); + boost::trim_left(content); } try { diff --git a/pdns/dnsbulktest.cc b/pdns/dnsbulktest.cc index 206f3e073c..8f8cd8b690 100644 --- a/pdns/dnsbulktest.cc +++ b/pdns/dnsbulktest.cc @@ -72,7 +72,7 @@ struct SendReceive typedef int Identifier; typedef DNSResult Answer; // ip int d_socket; - deque d_idqueue; + std::deque d_idqueue; typedef accumulator_set< double @@ -298,7 +298,7 @@ try if(limit && domains.size() >= limit) break; - trim_right(line); + boost::trim_right(line); if(line.empty() || line[0] == '#') continue; split=splitField(line,','); diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index f7980ad227..e3373f54bd 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -23,6 +23,7 @@ #include #include #include +#include #if defined (__OpenBSD__) || defined(__NetBSD__) // If this is not undeffed, __attribute__ wil be redefined by /usr/include/readline/rlstdc.h diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index f8ef4e2e95..cd7b0b9396 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -2078,7 +2078,7 @@ try #endif break; case 'l': - g_cmdLine.locals.push_back(trim_copy(string(optarg))); + g_cmdLine.locals.push_back(boost::trim_copy(string(optarg))); break; case 'u': g_cmdLine.uid=optarg; diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index c60dade1b6..ee45864ad6 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -32,7 +32,7 @@ UnknownRecordContent::UnknownRecordContent(const string& zone) vector parts; stringtok(parts, zone); // we need exactly 3 parts, except if the length field is set to 0 then we only need 2 - if (parts.size() != 3 && !(parts.size() == 2 && equals(parts.at(1), "0"))) { + if (parts.size() != 3 && !(parts.size() == 2 && boost::equals(parts.at(1), "0"))) { throw MOADNSException("Unknown record was stored incorrectly, need 3 fields, got " + std::to_string(parts.size()) + ": " + zone); } diff --git a/pdns/dnspcap.cc b/pdns/dnspcap.cc index bf3ef84690..c7d634504f 100644 --- a/pdns/dnspcap.cc +++ b/pdns/dnspcap.cc @@ -41,7 +41,7 @@ PcapPacketReader::PcapPacketReader(const string& fname) : d_fname(fname) checkedFread(&d_pfh); if (d_pfh.magic != 2712847316UL) { - throw runtime_error((format("PCAP file %s has bad magic %x, should be %x") % fname % d_pfh.magic % 2712847316UL).str()); + throw runtime_error((boost::format("PCAP file %s has bad magic %x, should be %x") % fname % d_pfh.magic % 2712847316UL).str()); } if( d_pfh.linktype==1) { @@ -56,7 +56,7 @@ PcapPacketReader::PcapPacketReader(const string& fname) : d_fname(fname) else if(d_pfh.linktype==113) { d_skipMediaHeader=16; } - else throw runtime_error((format("Unsupported link type %d") % d_pfh.linktype).str()); + else throw runtime_error((boost::format("Unsupported link type %d") % d_pfh.linktype).str()); d_runts = d_oversized = d_correctpackets = d_nonetheripudp = 0; } @@ -65,14 +65,14 @@ void PcapPacketReader::checkedFreadSize(void* ptr, size_t size) { int ret = fread(ptr, 1, size, d_fp.get()); if (ret < 0) { - unixDie( (format("Error reading %d bytes from %s") % size % d_fname).str()); + unixDie( (boost::format("Error reading %d bytes from %s") % size % d_fname).str()); } if(!ret) throw EofException(); if((size_t)ret != size) - throw EofException((format("Incomplete read from '%s', got only %d bytes") % d_fname % ret).str()); + throw EofException((boost::format("Incomplete read from '%s', got only %d bytes") % d_fname % ret).str()); } bool PcapPacketReader::getUDPPacket() @@ -87,7 +87,7 @@ try if(d_pheader.caplen > sizeof(d_buffer)) { d_oversized++; - throw runtime_error((format("Can't handle a %d byte packet, have space for %d") % d_pheader.caplen % sizeof(d_buffer)).str()); + throw runtime_error((boost::format("Can't handle a %d byte packet, have space for %d") % d_pheader.caplen % sizeof(d_buffer)).str()); } checkedFreadSize(d_buffer, d_pheader.caplen); diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index 40908377ed..8a15c9f58f 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -26,7 +26,6 @@ #include "dnsrecords.hh" #include "iputils.hh" - void DNSResourceRecord::setContent(const string &cont) { content = cont; switch(qtype.getCode()) { diff --git a/pdns/dnsreplay.cc b/pdns/dnsreplay.cc index c7cda449bb..1bfffd3fed 100644 --- a/pdns/dnsreplay.cc +++ b/pdns/dnsreplay.cc @@ -159,7 +159,7 @@ public: } private: - deque d_available; + std::deque d_available; } s_idmanager; @@ -493,8 +493,8 @@ static void pruneQids() static void printStats(uint64_t origWaitingFor=0, uint64_t weWaitingFor=0) { - format headerfmt ("%|9t|Questions - Pend. - Drop = Answers = (On time + Late) = (Err + Ok)\n"); - format datafmt("%s%|9t|%d %|21t|%d %|29t|%d %|36t|%d %|47t|%d %|57t|%d %|66t|%d %|72t|%d\n"); + boost::format headerfmt ("%|9t|Questions - Pend. - Drop = Answers = (On time + Late) = (Err + Ok)\n"); + boost::format datafmt("%s%|9t|%d %|21t|%d %|29t|%d %|36t|%d %|47t|%d %|57t|%d %|66t|%d %|72t|%d\n"); cerr< DNSCryptoKeyEngine::makeFromISCString(DNSKEYRecor while(std::getline(str, sline)) { tie(key,value)=splitField(sline, ':'); - trim(value); + boost::trim(value); if(pdns_iequals(key,"algorithm")) { algorithm = pdns_stou(value); stormap["algorithm"]=std::to_string(algorithm); @@ -267,7 +267,7 @@ void DNSCryptoKeyEngine::testMakers(unsigned int algo, maker_t* creator, maker_t while(std::getline(str, sline)) { tie(key,value)=splitField(sline, ':'); - trim(value); + boost::trim(value); if(pdns_iequals(key,"algorithm")) { algorithm = pdns_stou(value); stormap["algorithm"]=std::to_string(algorithm); diff --git a/pdns/dnstcpbench.cc b/pdns/dnstcpbench.cc index 68cfddb67d..aa461ac18d 100644 --- a/pdns/dnstcpbench.cc +++ b/pdns/dnstcpbench.cc @@ -268,7 +268,7 @@ try pair q; string line; while(stringfgets(fp.get(), line)) { - trim_right(line); + boost::trim_right(line); q=splitField(line, ' '); g_queries.push_back(BenchQuery(q.first, DNSRecordContent::TypeToNumber(q.second))); } diff --git a/pdns/lua-recursor4.cc b/pdns/lua-recursor4.cc index 34198a633a..f53d4a86fd 100644 --- a/pdns/lua-recursor4.cc +++ b/pdns/lua-recursor4.cc @@ -379,7 +379,7 @@ void RecursorLua4::postPrepareContext() d_lw->writeFunction("getStat", [](const std::string& str) { uint64_t result = 0; - optional value = getStatByName(str); + boost::optional value = getStatByName(str); if (value) { result = *value; } diff --git a/pdns/misc.cc b/pdns/misc.cc index 75918cb49e..be2a4744f3 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -1468,7 +1467,7 @@ std::vector getResolvers(const std::string& resolvConfPath) string line; while(std::getline(ifs, line)) { - boost::trim_right_if(line, is_any_of(" \r\n\x1a")); + boost::trim_right_if(line, boost::is_any_of(" \r\n\x1a")); boost::trim_left(line); // leading spaces, let's be nice string::size_type tpos = line.find_first_of(";#"); diff --git a/pdns/namespaces.hh b/pdns/namespaces.hh index 64ecaac4a8..b0bf01c8f6 100644 --- a/pdns/namespaces.hh +++ b/pdns/namespaces.hh @@ -20,59 +20,36 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #pragma once -#include -#include -#include -#include -#include -#include + #include -#include -#include -#include +#include +#include #include +#include #include -#include #include -#include +#include +#include -using std::vector; -using std::map; -using std::pair; -using std::make_pair; -using std::runtime_error; -using std::ostringstream; -using std::set; -using std::deque; using std::cerr; -using std::cout; using std::clog; +using std::cout; using std::endl; using std::ifstream; +using std::make_pair; +using std::make_tuple; +using std::map; +using std::max; +using std::min; using std::ofstream; using std::ostream; -using std::min; // these are a bit scary, everybody uses 'min' -using std::max; -using std::string; - -using boost::tie; +using std::ostringstream; +using std::pair; +using std::runtime_error; +using std::set; using std::shared_ptr; +using std::string; +using std::tie; +using std::tuple; using std::unique_ptr; -using boost::shared_array; -using boost::scoped_array; -using boost::tuple; -using boost::format; -using boost::make_tuple; -using boost::optional; -using boost::any_cast; -using boost::any; -using boost::function; -using boost::trim; -using boost::trim_copy; -using boost::trim_left; -using boost::trim_right; -using boost::is_any_of; -using boost::trim_right_copy_if; -using boost::equals; -using boost::ends_with; -using boost::iends_with; +using std::vector; diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index d22c8e9843..05277dc57d 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -58,6 +58,7 @@ #include #include "sortlist.hh" #include "sstuff.hh" +#include #include #include #include @@ -145,7 +146,7 @@ thread_local std::shared_ptr t_udrDBp; #endif /* NOD_ENABLED */ __thread struct timeval g_now; // timestamp, updated (too) frequently -typedef vector > > deferredAdd_t; +typedef vector > > deferredAdd_t; // for communicating with our threads // effectively readonly after startup @@ -444,7 +445,7 @@ LWResult::Result arecvtcp(string& data, const size_t len, Socket* sock, const bo static void handleGenUDPQueryResponse(int fd, FDMultiplexer::funcparam_t& var) { - PacketID pident=*any_cast(&var); + PacketID pident=*boost::any_cast(&var); char resp[512]; ComboAddress fromaddr; socklen_t addrlen=sizeof(fromaddr); @@ -690,7 +691,7 @@ LWResult::Result asendto(const char *data, size_t len, int flags, LWResult::Result arecvfrom(std::string& packet, int flags, const ComboAddress& fromaddr, size_t *d_len, uint16_t id, const DNSName& domain, uint16_t qtype, int fd, const struct timeval* now) { - static optional nearMissLimit; + static boost::optional nearMissLimit; if(!nearMissLimit) nearMissLimit=::arg().asNum("spoof-nearmiss-max"); @@ -2207,7 +2208,7 @@ static bool handleTCPReadResult(int fd, ssize_t bytes) static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) { - shared_ptr conn=any_cast >(var); + shared_ptr conn=boost::any_cast >(var); if (conn->state == TCPConnection::PROXYPROTOCOLHEADER) { ssize_t bytes = recv(conn->getFD(), &conn->data.at(conn->proxyProtocolGot), conn->proxyProtocolNeed, 0); @@ -3762,10 +3763,10 @@ static void handleRCC(int fd, FDMultiplexer::funcparam_t& var) static void handleTCPClientReadable(int fd, FDMultiplexer::funcparam_t& var) { - PacketID* pident=any_cast(&var); + PacketID* pident=boost::any_cast(&var); // cerr<<"handleTCPClientReadable called for fd "<inNeeded: "<inNeeded<<", "<sock->getHandle()< buffer(new char[pident->inNeeded]); + boost::shared_array buffer(new char[pident->inNeeded]); ssize_t ret=recv(fd, buffer.get(), pident->inNeeded,0); if(ret > 0) { @@ -3793,7 +3794,7 @@ static void handleTCPClientReadable(int fd, FDMultiplexer::funcparam_t& var) static void handleTCPClientWritable(int fd, FDMultiplexer::funcparam_t& var) { - PacketID* pid=any_cast(&var); + PacketID* pid=boost::any_cast(&var); ssize_t ret=send(fd, pid->outMSG.c_str() + pid->outPos, pid->outMSG.size() - pid->outPos,0); if(ret > 0) { pid->outPos+=(ssize_t)ret; @@ -3829,7 +3830,7 @@ static void doResends(MT_t::waiters_t::iterator& iter, PacketID resend, const st static void handleUDPServerResponse(int fd, FDMultiplexer::funcparam_t& var) { - PacketID pid=any_cast(var); + PacketID pid=boost::any_cast(var); ssize_t len; std::string packet; packet.resize(g_outgoingEDNSBufsize); @@ -4089,7 +4090,7 @@ void parseACLs() pos=line.find('#'); if(pos!=string::npos) line.resize(pos); - trim(line); + boost::trim(line); if(line.empty()) continue; @@ -4154,8 +4155,8 @@ static std::map > parseCPUMap() try { auto headers = splitField(part, '='); - trim(headers.first); - trim(headers.second); + boost::trim(headers.first); + boost::trim(headers.second); unsigned int threadId = pdns_stou(headers.first); std::vector cpus; @@ -5017,7 +5018,7 @@ try expired_t expired=t_fdm->getTimeouts(g_now); for(expired_t::iterator i=expired.begin() ; i != expired.end(); ++i) { - shared_ptr conn=any_cast >(i->second); + shared_ptr conn=boost::any_cast >(i->second); if(g_logCommonErrors) g_log<d_remote.toStringWithPort() <removeReadFD(i->first); diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 97acfa0638..9325291efb 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -188,7 +188,7 @@ static void dbBench(const std::string& fname) } string line; while(getline(ifs,line)) { - trim(line); + boost::trim(line); domains.push_back(line); } } @@ -2918,7 +2918,7 @@ try while(getline(ifs, line)) { if(line[0]=='-') continue; - trim(line); + boost::trim(line); interim += line; } B64Decode(interim, raw); diff --git a/pdns/rec-snmp.cc b/pdns/rec-snmp.cc index f7a4138a23..9c50662239 100644 --- a/pdns/rec-snmp.cc +++ b/pdns/rec-snmp.cc @@ -147,7 +147,7 @@ static int handleCounter64Stats(netsnmp_mib_handler* handler, return SNMP_ERR_GENERR; } - optional value = getStatByName(it->second); + boost::optional value = getStatByName(it->second); if (value) { return RecursorSNMPAgent::setCounter64Value(requests, *value); } else { diff --git a/pdns/rec_channel.hh b/pdns/rec_channel.hh index 14b36cc0d7..395c1a165c 100644 --- a/pdns/rec_channel.hh +++ b/pdns/rec_channel.hh @@ -33,6 +33,7 @@ #include "dnsname.hh" #include "sholder.hh" #include +#include extern GlobalStateHolder g_dontThrottleNames; extern GlobalStateHolder g_dontThrottleNetmasks; diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 150ec8014e..a606c07861 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -41,7 +41,7 @@ std::mutex g_carbon_config_lock; static map d_get32bitpointers; static map*> d_getatomics; -static map > d_get64bitmembers; +static map > d_get64bitmembers; static std::mutex d_dynmetricslock; struct dynmetrics { std::atomic *d_ptr; @@ -82,7 +82,7 @@ static void addGetStat(const string& name, const std::atomic* place) d_getatomics[name]=place; } -static void addGetStat(const string& name, function f ) +static void addGetStat(const string& name, std::function f ) { d_get64bitmembers[name]=f; } @@ -114,9 +114,9 @@ std::atomic* getDynMetric(const std::string& str, const std::stri return ret.d_ptr; } -static optional get(const string& name) +static boost::optional get(const string& name) { - optional ret; + boost::optional ret; if(d_get32bitpointers.count(name)) return *d_get32bitpointers.find(name)->second; @@ -133,7 +133,7 @@ static optional get(const string& name) return ret; } -optional getStatByName(const std::string& name) +boost::optional getStatByName(const std::string& name) { return get(name); } @@ -188,7 +188,7 @@ static string doGet(T begin, T end) string ret; for(T i=begin; i != end; ++i) { - optional num=get(*i); + boost::optional num=get(*i); if(num) ret+=std::to_string(*num)+"\n"; else @@ -1383,7 +1383,7 @@ static string doGenericTopRemotes(pleaseremotefunc_t func) ostringstream ret; ret<<"Over last "< #include #include +#include #include "packetcache.hh" #include "validate.hh" diff --git a/pdns/recursordist/negcache.hh b/pdns/recursordist/negcache.hh index e7bdf3fe83..2f37d421f3 100644 --- a/pdns/recursordist/negcache.hh +++ b/pdns/recursordist/negcache.hh @@ -25,6 +25,7 @@ #include #include #include +#include #include "dnsparser.hh" #include "dnsname.hh" #include "dns.hh" diff --git a/pdns/recursordist/test-syncres_cc1.cc b/pdns/recursordist/test-syncres_cc1.cc index e9523f0278..9d9a6121d3 100644 --- a/pdns/recursordist/test-syncres_cc1.cc +++ b/pdns/recursordist/test-syncres_cc1.cc @@ -585,7 +585,7 @@ BOOST_AUTO_TEST_CASE(test_forward_ns_send_refused) vector ret; int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret); BOOST_CHECK_EQUAL(res, RCode::ServFail); - BOOST_CHECK_EQUAL(ret.size(), 0); + BOOST_CHECK_EQUAL(ret.size(), 0U); BOOST_CHECK_EQUAL(downServers.size(), 2U); BOOST_CHECK_EQUAL(queriesCount, 2U); @@ -636,7 +636,7 @@ BOOST_AUTO_TEST_CASE(test_forward_ns_send_servfail) vector ret; int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret); BOOST_CHECK_EQUAL(res, RCode::ServFail); - BOOST_CHECK_EQUAL(ret.size(), 0); + BOOST_CHECK_EQUAL(ret.size(), 0U); BOOST_CHECK_EQUAL(downServers.size(), 2U); BOOST_CHECK_EQUAL(queriesCount, 2U); diff --git a/pdns/reczones.cc b/pdns/reczones.cc index 5c049b1c3a..5a92d37f6f 100644 --- a/pdns/reczones.cc +++ b/pdns/reczones.cc @@ -372,8 +372,8 @@ std::shared_ptr parseAuthAndForwards() if ((*iter).find('=') == string::npos) throw PDNSException("Error parsing '" + *iter + "', missing ="); pair headers=splitField(*iter, '='); - trim(headers.first); - trim(headers.second); + boost::trim(headers.first); + boost::trim(headers.second); // headers.first=toCanonic("", headers.first); if(n==0) { ad.d_rdForward = false; @@ -429,14 +429,14 @@ std::shared_ptr parseAuthAndForwards() int linenum=0; uint64_t before = newMap->size(); while(linenum++, stringfgets(fp.get(), line)) { - trim(line); + boost::trim(line); if (line[0] == '#') // Comment line, skip to the next line continue; string domain, instructions; tie(domain, instructions)=splitField(line, '='); instructions = splitField(instructions, '#').first; // Remove EOL comments - trim(domain); - trim(instructions); + boost::trim(domain); + boost::trim(instructions); if(domain.empty() && instructions.empty()) { // empty line continue; } @@ -478,7 +478,7 @@ std::shared_ptr parseAuthAndForwards() pos=line.find('#'); if(pos!=string::npos) line.resize(pos); - trim(line); + boost::trim(line); if(line.empty()) continue; parts.clear(); diff --git a/pdns/resolve-context.hh b/pdns/resolve-context.hh index ab298b09cd..7ad9bf553b 100644 --- a/pdns/resolve-context.hh +++ b/pdns/resolve-context.hh @@ -4,6 +4,7 @@ #ifdef HAVE_PROTOBUF #include +#include #endif struct ResolveContext { diff --git a/pdns/responsestats.hh b/pdns/responsestats.hh index 884d49d0f2..ba966ffe3d 100644 --- a/pdns/responsestats.hh +++ b/pdns/responsestats.hh @@ -20,7 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #pragma once -#include "misc.hh" + +#include + #include "dnspacket.hh" class ResponseStats diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 98cd249586..0d17ce74a0 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -247,7 +247,7 @@ void TCPNameserver::doConnection(int fd) setNonBlocking(fd); try { int mesgsize=65535; - scoped_array mesg(new char[mesgsize]); + boost::scoped_array mesg(new char[mesgsize]); DLOG(g_log<<"TCP Connection accepted on fd "< v; rtr.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); auto alpn = v.begin()->getALPN(); - BOOST_CHECK_EQUAL(alpn.size(), 1); + BOOST_CHECK_EQUAL(alpn.size(), 1U); auto val = alpn.begin(); BOOST_CHECK_EQUAL(*val, "h2"); @@ -51,9 +51,9 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_alpn) { source = "alpn=h2,h3"; RecordTextReader rtr2(source); rtr2.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); alpn = v.begin()->getALPN(); - BOOST_CHECK_EQUAL(alpn.size(), 2); + BOOST_CHECK_EQUAL(alpn.size(), 2U); val = alpn.begin(); BOOST_CHECK_EQUAL(*val, "h2"); val++; @@ -71,9 +71,9 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_mandatory) { RecordTextReader rtr(source); set v; rtr.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); auto m = v.begin()->getMandatory(); - BOOST_CHECK_EQUAL(m.size(), 1); + BOOST_CHECK_EQUAL(m.size(), 1U); auto val = m.begin(); BOOST_CHECK(*val == SvcParam::alpn); @@ -87,9 +87,9 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_mandatory) { source = "mandatory=alpn,ipv4hint"; RecordTextReader rtr2("mandatory=alpn,ipv4hint"); rtr2.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); m = v.begin()->getMandatory(); - BOOST_CHECK_EQUAL(m.size(), 2); + BOOST_CHECK_EQUAL(m.size(), 2U); val = m.begin(); BOOST_CHECK(*val == SvcParam::alpn); val++; @@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_no_default_alpn) { RecordTextReader rtr(source); set v; rtr.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); auto k = v.begin()->getKey(); BOOST_CHECK(k == SvcParam::no_default_alpn); @@ -127,11 +127,11 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_ipv4hint) { RecordTextReader rtr(source); set v; rtr.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); auto k = v.begin()->getKey(); BOOST_CHECK(k == SvcParam::ipv4hint); auto val = v.begin()->getIPHints(); - BOOST_CHECK_EQUAL(val.size(), 1); + BOOST_CHECK_EQUAL(val.size(), 1U); BOOST_CHECK_EQUAL(val.begin()->toString(), "192.0.2.1"); // Check the writer @@ -144,12 +144,12 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_ipv4hint) { source = "ipv4hint=192.0.2.1,192.0.2.2,192.0.2.3"; RecordTextReader rtr2(source); rtr2.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); k = v.begin()->getKey(); BOOST_CHECK(k == SvcParam::ipv4hint); val = v.begin()->getIPHints(); - BOOST_CHECK_EQUAL(val.size(), 3); + BOOST_CHECK_EQUAL(val.size(), 3U); auto valit = val.begin(); BOOST_CHECK_EQUAL(valit->toString(), "192.0.2.1"); valit++; @@ -177,11 +177,11 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_ipv6hint) { RecordTextReader rtr(source); set v; rtr.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); auto k = v.begin()->getKey(); BOOST_CHECK(k == SvcParam::ipv6hint); auto val = v.begin()->getIPHints(); - BOOST_CHECK_EQUAL(val.size(), 1); + BOOST_CHECK_EQUAL(val.size(), 1U); BOOST_CHECK_EQUAL(val.begin()->toString(), "2001:db8::1"); // Check the writer @@ -194,12 +194,12 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_ipv6hint) { source = "ipv6hint=2001:db8::1,2001:db8::2,2001:db8::3"; RecordTextReader rtr2(source); rtr2.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); k = v.begin()->getKey(); BOOST_CHECK(k == SvcParam::ipv6hint); val = v.begin()->getIPHints(); - BOOST_CHECK_EQUAL(val.size(), 3); + BOOST_CHECK_EQUAL(val.size(), 3U); auto valit = val.begin(); BOOST_CHECK_EQUAL(valit->toString(), "2001:db8::1"); valit++; @@ -227,7 +227,7 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_port) { RecordTextReader rtr(source); set v; rtr.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); auto k = v.begin()->getKey(); BOOST_CHECK(k == SvcParam::port); auto val = v.begin()->getPort(); @@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_generic) { RecordTextReader rtr(source); set v; rtr.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); auto k = v.begin()->getKey(); BOOST_CHECK(k == 666); auto val = v.begin()->getValue(); @@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_generic) { source = "key666=\"blablabla\""; RecordTextReader rtr4(source); rtr4.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); k = v.begin()->getKey(); BOOST_CHECK(k == SvcParam::keyFromString("key666")); val = v.begin()->getValue(); @@ -302,7 +302,7 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_multiple) { RecordTextReader rtr("key666=foobar echconfig=\"dG90YWxseSBib2d1cyBlY2hjb25maWcgdmFsdWU=\" ipv6hint=2001:db8::1 alpn=h2,h3 mandatory=alpn ipv4hint=192.0.2.1,192.0.2.2"); // out of order, resulting set should be in-order set v; rtr.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 6); + BOOST_CHECK_EQUAL(v.size(), 6U); auto vit = v.begin(); // Check ordering @@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_echconfig) { RecordTextReader rtr(source); set v; rtr.xfrSvcParamKeyVals(v); - BOOST_CHECK_EQUAL(v.size(), 1); + BOOST_CHECK_EQUAL(v.size(), 1U); auto k = v.begin()->getKey(); BOOST_CHECK(k == SvcParam::echconfig); auto val = v.begin()->getEchConfig(); @@ -353,4 +353,4 @@ BOOST_AUTO_TEST_CASE(test_xfrSvcParamKeyVals_echconfig) { BOOST_CHECK_EQUAL(source, target); } -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/pdns/zone2json.cc b/pdns/zone2json.cc index b617e8239e..e6cfcbd2a7 100644 --- a/pdns/zone2json.cc +++ b/pdns/zone2json.cc @@ -65,7 +65,7 @@ static Json::object emitRecord(const string& zoneName, const DNSName &DNSqname, string::size_type pos = content.find_first_not_of("0123456789"); if(pos != string::npos) boost::erase_head(content, pos); - trim_left(content); + boost::trim_left(content); } Json::object dict; diff --git a/pdns/zone2sql.cc b/pdns/zone2sql.cc index f86db15122..887259f92c 100644 --- a/pdns/zone2sql.cc +++ b/pdns/zone2sql.cc @@ -167,7 +167,7 @@ static void emitRecord(const DNSName& zoneName, const DNSName &DNSqname, const s string::size_type pos = content.find_first_not_of("0123456789"); if(pos != string::npos) boost::erase_head(content, pos); - trim_left(content); + boost::trim_left(content); } cout<<"insert into records (domain_id, name, type,content,ttl,prio,disabled) select id ,"<< diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index 9c171c6164..323c9dee0d 100644 --- a/pdns/zoneparser-tng.cc +++ b/pdns/zoneparser-tng.cc @@ -295,7 +295,7 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment) if(!getTemplateLine() && !getLine()) return false; - boost::trim_right_if(d_line, is_any_of(" \t\r\n\x1a")); + boost::trim_right_if(d_line, boost::is_any_of(" \t\r\n\x1a")); if(comment) comment->clear(); if(comment && d_line.find(';') != string::npos) @@ -313,7 +313,7 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment) if(d_line[0]=='$') { string command=makeString(d_line, d_parts[0]); if(pdns_iequals(command,"$TTL") && d_parts.size() > 1) { - d_defaultttl=makeTTLFromZone(trim_right_copy_if(makeString(d_line, d_parts[1]), is_any_of(";"))); + d_defaultttl=makeTTLFromZone(trim_right_copy_if(makeString(d_line, d_parts[1]), boost::is_any_of(";"))); d_havedollarttl=true; } else if(pdns_iequals(command,"$INCLUDE") && d_parts.size() > 1 && d_fromfile) { @@ -439,7 +439,7 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment) // rr.content=d_line.substr(range.first); rr.content.assign(d_line, range.first, string::npos); chopComment(rr.content); - trim_if(rr.content, is_any_of(" \r\n\t\x1a")); + trim_if(rr.content, boost::is_any_of(" \r\n\t\x1a")); if(rr.content.size()==1 && rr.content[0]=='@') rr.content=d_zonename.toString(); @@ -447,9 +447,9 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment) if(findAndElide(rr.content, '(')) { // have found a ( and elided it if(!findAndElide(rr.content, ')')) { while(getLine()) { - trim_right(d_line); + boost::trim_right(d_line); chopComment(d_line); - trim(d_line); + boost::trim(d_line); bool ended = findAndElide(d_line, ')'); rr.content+=" "+d_line; @@ -458,7 +458,7 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment) } } } - trim_if(rr.content, is_any_of(" \r\n\t\x1a")); + boost::trim_if(rr.content, boost::is_any_of(" \r\n\t\x1a")); if (d_upgradeContent && DNSRecordContent::isUnknownType(qtypeString)) { rr.content = DNSRecordContent::upgradeContent(rr.qname, rr.qtype, rr.content); diff --git a/pdns/zoneparser-tng.hh b/pdns/zoneparser-tng.hh index 1f3fad4322..f490f58d3d 100644 --- a/pdns/zoneparser-tng.hh +++ b/pdns/zoneparser-tng.hh @@ -24,6 +24,7 @@ #include #include #include +#include #include "namespaces.hh" @@ -36,7 +37,7 @@ public: ~ZoneParserTNG(); bool get(DNSResourceRecord& rr, std::string* comment=0); typedef runtime_error exception; - typedef deque > parts_t; + typedef std::deque > parts_t; DNSName getZoneName(); string getLineOfFile(); // for error reporting purposes pair getLineNumAndFile(); // idem