Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more clang-tidy fixups #15054

Merged
merged 5 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/geoipbackend/geoipinterface-dat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class GeoIPInterfaceDAT : public GeoIPInterface
free(result);
gl.netmask = tmp_gl.netmask;
// reduce space to dash
ret = boost::replace_all_copy(ret, " ", "-");
std::replace(ret.begin(), ret.end(), ' ', '-');
return true;
}
}
Expand All @@ -306,7 +306,7 @@ class GeoIPInterfaceDAT : public GeoIPInterface
free(result);
gl.netmask = tmp_gl.netmask;
// reduce space to dash
ret = boost::replace_all_copy(ret, " ", "-");
std::replace(ret.begin(), ret.end(), ' ', '-');
return true;
}
}
Expand Down
22 changes: 12 additions & 10 deletions pdns/axfr-retriever.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ using pdns::resolver::parseResult;

AXFRRetriever::AXFRRetriever(const ComboAddress& remote,
const DNSName& domain,
const TSIGTriplet& tt,
const TSIGTriplet& tsigConf,
const ComboAddress* laddr,
size_t maxReceivedBytes,
uint16_t timeout)
: d_buf(65536), d_tsigVerifier(tt, remote, d_trc), d_receivedBytes(0), d_maxReceivedBytes(maxReceivedBytes)
uint16_t timeout) :
d_buf(65536), d_tsigVerifier(tsigConf, remote, d_trc), d_maxReceivedBytes(maxReceivedBytes)
{
ComboAddress local;
if (laddr != nullptr) {
Expand All @@ -59,17 +59,19 @@ AXFRRetriever::AXFRRetriever(const ComboAddress& remote,
vector<uint8_t> packet;
DNSPacketWriter pw(packet, domain, QType::AXFR);
pw.getHeader()->id = dns_random_uint16();

if(!tt.name.empty()) {
if (tt.algo == DNSName("hmac-md5"))
d_trc.d_algoName = tt.algo + DNSName("sig-alg.reg.int");
else
d_trc.d_algoName = tt.algo;

if (!tsigConf.name.empty()) {
if (tsigConf.algo == DNSName("hmac-md5")) {
d_trc.d_algoName = tsigConf.algo + DNSName("sig-alg.reg.int");
}
else {
d_trc.d_algoName = tsigConf.algo;
}
d_trc.d_time = time(nullptr);
d_trc.d_fudge = 300;
d_trc.d_origID=ntohs(pw.getHeader()->id);
d_trc.d_eRcode=0;
addTSIG(pw, d_trc, tt.name, tt.secret, "", false);
addTSIG(pw, d_trc, tsigConf.name, tsigConf.secret, "", false);
}

uint16_t replen=htons(packet.size());
Expand Down
2 changes: 1 addition & 1 deletion pdns/axfr-retriever.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ class AXFRRetriever : public boost::noncopyable
TSIGRecordContent d_trc;
TSIGTCPVerifier d_tsigVerifier;

size_t d_receivedBytes;
size_t d_receivedBytes{0};
size_t d_maxReceivedBytes;
};
31 changes: 14 additions & 17 deletions pdns/bindparserclasses.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
class BindDomainInfo
{
public:
BindDomainInfo() : hadFileDirective(false), d_dev(0), d_ino(0)
{}

void clear()
{
name=DNSName();
Expand All @@ -50,10 +47,10 @@ public:
vector<ComboAddress> primaries;
set<string> alsoNotify;
string type;
bool hadFileDirective;
dev_t d_dev;
ino_t d_ino;
bool hadFileDirective{false};

dev_t d_dev{0};
ino_t d_ino{0};

bool operator<(const BindDomainInfo& b) const
{
Expand All @@ -66,14 +63,14 @@ extern FILE *yyin;
class BindParser
{
public:
BindParser() : d_dir("."), d_verbose(false)
{
yyin=0;
extern int include_stack_ptr;
include_stack_ptr=0;
bind_directory=d_dir.c_str();
}
BindParser()
{
yyin = 0;
extern int include_stack_ptr;
include_stack_ptr = 0;

bind_directory = d_dir.c_str();
}
~BindParser()
{
if(yyin) {
Expand All @@ -90,9 +87,9 @@ class BindParser
void addAlsoNotify(const string &host);
set<string> & getAlsoNotify() { return this->alsoNotify; }
private:
string d_dir;
string d_dir{"."};
typedef map<DNSName,string> zonedomain_t;
set<string> alsoNotify;
vector<BindDomainInfo> d_zonedomains;
bool d_verbose;
bool d_verbose{false};
};
7 changes: 2 additions & 5 deletions pdns/comment.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@
class Comment
{
public:
Comment() : modified_at(0), domain_id(0) {};
~Comment() = default;

// data
DNSName qname; //!< the name of the associated RRset, for example: www.powerdns.com
time_t modified_at;
time_t modified_at{0};
string account; //!< account last updating this comment
string content; //!< The actual comment. Example: blah blah

int domain_id;
int domain_id{0};
QType qtype; //!< qtype of the associated RRset, ie A, CNAME, MX etc
};
5 changes: 3 additions & 2 deletions pdns/communicator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <utility>
using namespace boost::multi_index;

#include <unistd.h>
Expand Down Expand Up @@ -234,8 +235,8 @@ private:

struct RemoveSentinel
{
explicit RemoveSentinel(const DNSName& dn, CommunicatorClass* cc) :
d_dn(dn), d_cc(cc)
explicit RemoveSentinel(DNSName dn, CommunicatorClass* cc) :
d_dn(std::move(dn)), d_cc(cc)
{}

~RemoveSentinel()
Expand Down
4 changes: 2 additions & 2 deletions pdns/dnsbackend.hh
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ private:
class BackendFactory
{
public:
BackendFactory(const string& name) :
d_name(name) {}
BackendFactory(string name) :
d_name(std::move(name)) {}
virtual ~BackendFactory() = default;
virtual DNSBackend* make(const string& suffix) = 0;
virtual DNSBackend* makeMetadataOnly(const string& suffix)
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdistdist/dnsdist-actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ DNSAction::Action DNSAction::typeFromString(const std::string& str)
};

auto lower = boost::to_lower_copy(str);
boost::replace_all(lower, "-", "");
lower.erase(std::remove(lower.begin(), lower.end(), '-'), lower.end());
miodvallat marked this conversation as resolved.
Show resolved Hide resolved
auto mappingIt = s_mappings.find(lower);
if (mappingIt != s_mappings.end()) {
return mappingIt->second;
Expand Down
16 changes: 8 additions & 8 deletions pdns/dnsdistdist/dnsdist-carbon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)

for (const auto& state : dnsdist::configuration::getCurrentRuntimeConfiguration().d_backends) {
string serverName = state->getName().empty() ? state->d_config.remote.toStringWithPort() : state->getName();
boost::replace_all(serverName, ".", "_");
std::replace(serverName.begin(), serverName.end(), '.', '_');
string base = namespace_name;
base += ".";
base += hostname;
Expand Down Expand Up @@ -123,7 +123,7 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)
}

string frontName = front->local.toStringWithPort() + (front->udpFD >= 0 ? "_udp" : "_tcp");
boost::replace_all(frontName, ".", "_");
std::replace(frontName.begin(), frontName.end(), '.', '_');
auto dupPair = frontendDuplicates.insert({frontName, 1});
if (!dupPair.second) {
frontName += "_" + std::to_string(dupPair.first->second);
Expand Down Expand Up @@ -180,7 +180,7 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)

for (const auto& entry : dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools) {
string poolName = entry.first;
boost::replace_all(poolName, ".", "_");
std::replace(poolName.begin(), poolName.end(), '.', '_');
if (poolName.empty()) {
poolName = "_default_";
}
Expand Down Expand Up @@ -228,10 +228,10 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)
const string base = "dnsdist." + hostname + ".main.doh.";
for (const auto& doh : dnsdist::getDoHFrontends()) {
string name = doh->d_tlsContext.d_addr.toStringWithPort();
boost::replace_all(name, ".", "_");
boost::replace_all(name, ":", "_");
boost::replace_all(name, "[", "_");
boost::replace_all(name, "]", "_");
std::replace(name.begin(), name.end(), '.', '_');
std::replace(name.begin(), name.end(), ':', '_');
std::replace(name.begin(), name.end(), '[', '_');
std::replace(name.begin(), name.end(), ']', '_');

auto dupPair = dohFrontendDuplicates.insert({name, 1});
if (!dupPair.second) {
Expand Down Expand Up @@ -274,7 +274,7 @@ static bool doOneCarbonExport(const Carbon::Endpoint& endpoint)
auto records = dnsdist::QueryCount::g_queryCountRecords.write_lock();
for (const auto& record : *records) {
qname = record.first;
boost::replace_all(qname, ".", "_");
std::replace(qname.begin(), qname.end(), '.', '_');
str << "dnsdist.querycount." << qname << ".queries " << record.second << " " << now << "\r\n";
}
records->clear();
Expand Down
4 changes: 2 additions & 2 deletions pdns/dnsdistdist/dnsdist-secpoll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ void doSecPoll(const std::string& suffix)
queriedName += '.';
}

boost::replace_all(queriedName, "+", "_");
boost::replace_all(queriedName, "~", "_");
std::replace(queriedName.begin(), queriedName.end(), '+', '_');
std::replace(queriedName.begin(), queriedName.end(), '~', '_');

try {
std::string status = getSecPollStatus(queriedName);
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdistdist/dnsdist-web.cc
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ static void handlePrometheus(const YaHTTP::Request& req, YaHTTP::Response& resp)
serverName = state->getName();
}

boost::replace_all(serverName, ".", "_");
std::replace(serverName.begin(), serverName.end(), '.', '_');

const std::string label = boost::str(boost::format(R"({server="%1%",address="%2%"})")
% serverName % state->d_config.remote.toStringWithPort());
Expand Down
4 changes: 2 additions & 2 deletions pdns/dnsdistdist/doh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1145,8 +1145,8 @@ static int doh_handler(h2o_handler_t *self, h2o_req_t *req)
if (pos != string::npos) {
// need to base64url decode this
string sdns(path.substr(pos+5));
boost::replace_all(sdns,"-", "+");
boost::replace_all(sdns,"_", "/");
std::replace(sdns.begin(), sdns.end(), '-', '+');
std::replace(sdns.begin(), sdns.end(), '_', '/');
// re-add padding that may have been missing
switch (sdns.size() % 4) {
case 2:
Expand Down
4 changes: 3 additions & 1 deletion pdns/dnsname.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <cstring>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <strings.h>
Expand Down Expand Up @@ -306,7 +307,8 @@ extern const DNSName g_rootdnsname, g_wildcarddnsname;
template<typename T>
struct SuffixMatchTree
{
SuffixMatchTree(const std::string& name="", bool endNode_=false) : d_name(name), endNode(endNode_)
SuffixMatchTree(std::string name = "", bool endNode_ = false) :
d_name(std::move(name)), endNode(endNode_)
{}

SuffixMatchTree(const SuffixMatchTree& rhs): d_name(rhs.d_name), children(rhs.children), endNode(rhs.endNode)
Expand Down
15 changes: 9 additions & 6 deletions pdns/dnsrecords.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "rcpgenerator.hh"
#include <set>
#include <bitset>
#include <utility>
#include "namespaces.hh"
#include "iputils.hh"
#include "svc-records.hh"
Expand Down Expand Up @@ -289,8 +290,8 @@ private:
class NSRecordContent : public DNSRecordContent
{
public:
includeboilerplate(NS)
explicit NSRecordContent(const DNSName& content) : d_content(content){}
includeboilerplate(NS) explicit NSRecordContent(DNSName content) :
d_content(std::move(content)) {}
const DNSName& getNS() const { return d_content; }
bool operator==(const DNSRecordContent& rhs) const override
{
Expand All @@ -310,8 +311,8 @@ private:
class PTRRecordContent : public DNSRecordContent
{
public:
includeboilerplate(PTR)
explicit PTRRecordContent(const DNSName& content) : d_content(content){}
includeboilerplate(PTR) explicit PTRRecordContent(DNSName content) :
d_content(std::move(content)) {}
const DNSName& getContent() const { return d_content; }
[[nodiscard]] size_t sizeEstimate() const override
{
Expand All @@ -325,7 +326,8 @@ class CNAMERecordContent : public DNSRecordContent
{
public:
includeboilerplate(CNAME)
CNAMERecordContent(const DNSName& content) : d_content(content){}
CNAMERecordContent(DNSName content) :
d_content(std::move(content)) {}
DNSName getTarget() const { return d_content; }
[[nodiscard]] size_t sizeEstimate() const override
{
Expand Down Expand Up @@ -358,7 +360,8 @@ class DNAMERecordContent : public DNSRecordContent
{
public:
includeboilerplate(DNAME)
DNAMERecordContent(const DNSName& content) : d_content(content){}
DNAMERecordContent(DNSName content) :
d_content(std::move(content)) {}
const DNSName& getTarget() const { return d_content; }
[[nodiscard]] size_t sizeEstimate() const override
{
Expand Down
6 changes: 3 additions & 3 deletions pdns/dnswriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@

*/


template <typename Container> GenericDNSPacketWriter<Container>::GenericDNSPacketWriter(Container& content, const DNSName& qname, uint16_t qtype, uint16_t qclass, uint8_t opcode)
: d_content(content), d_qname(qname), d_canonic(false), d_lowerCase(false)
template <typename Container>
GenericDNSPacketWriter<Container>::GenericDNSPacketWriter(Container& content, const DNSName& qname, uint16_t qtype, uint16_t qclass, uint8_t opcode) :
d_content(content), d_qname(qname)
{
d_content.clear();
dnsheader dnsheader;
Expand Down
4 changes: 2 additions & 2 deletions pdns/dnswriter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ private:
DNSName d_qname;

uint16_t d_truncatemarker; // end of header, for truncate
DNSResourceRecord::Place d_recordplace;
bool d_canonic, d_lowerCase, d_compress{false};
DNSResourceRecord::Place d_recordplace{DNSResourceRecord::QUESTION};
bool d_canonic{false}, d_lowerCase{false}, d_compress{false};
};

using DNSPacketWriter = GenericDNSPacketWriter<std::vector<uint8_t>>;
Expand Down
7 changes: 4 additions & 3 deletions pdns/inflighter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ struct TimeTag{};
template<typename Container, typename SenderReceiver> class Inflighter
{
public:
Inflighter(Container& c, SenderReceiver& sr) : d_container(c), d_sr(sr), d_init(false)
Inflighter(Container& c, SenderReceiver& sr) :
d_container(c), d_sr(sr)
{
d_burst = 2;
d_maxInFlight = 5;
Expand Down Expand Up @@ -99,8 +100,8 @@ template<typename Container, typename SenderReceiver> class Inflighter

ttdwatch_t d_ttdWatch;
typename Container::iterator d_iter;
bool d_init;
bool d_init{false};

uint64_t d_unexpectedResponse, d_timeouts;
};

Expand Down
2 changes: 1 addition & 1 deletion pdns/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void Logger::setName(const string& _name)
}

Logger::Logger(string n, int facility) :
name(std::move(n)), flags(LOG_PID | LOG_NDELAY), d_facility(facility), d_loglevel(Logger::None), consoleUrgency(Error), opened(false), d_disableSyslog(false)
name(std::move(n)), flags(LOG_PID | LOG_NDELAY), d_facility(facility)
{
open();
}
Expand Down
Loading
Loading