From 5708a72941d6b54f8a9823631e9baf1e3a43c720 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 27 Mar 2018 14:28:01 +0200 Subject: [PATCH] Use an initialization list instead of assigning values in the ctor body --- pdns/dnsdist.hh | 17 ++++++++++++++--- pdns/dnsname.hh | 10 ++-------- pdns/dnsparser.cc | 3 +-- pdns/iputils.hh | 4 ++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 862efa60b..c4650c233 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -128,6 +128,19 @@ public: struct DynBlock { + DynBlock(): action(DNSAction::Action::None) + { + } + + DynBlock(const std::string& reason_, const struct timespec& until_, const DNSName& domain_, DNSAction::Action action_): reason(reason_), until(until_), domain(domain_), action(action_) + { + } + + DynBlock(const DynBlock& rhs): reason(rhs.reason), until(rhs.until), domain(rhs.domain), action(rhs.action) + { + blocks.store(rhs.blocks); + } + DynBlock& operator=(const DynBlock& rhs) { reason=rhs.reason; @@ -324,12 +337,10 @@ struct ClientState; struct IDState { IDState() : origFD(-1), sentTime(true), delayMsec(0), tempFailureTTL(boost::none) { origDest.sin4.sin_family = 0;} - IDState(const IDState& orig) + IDState(const IDState& orig): origRemote(orig.origRemote), origDest(orig.origDest) { origFD = orig.origFD; origID = orig.origID; - origRemote = orig.origRemote; - origDest = orig.origDest; delayMsec = orig.delayMsec; tempFailureTTL = orig.tempFailureTTL; age.store(orig.age.load()); diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index 7307da4ed..7e0419f31 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -179,9 +179,7 @@ inline bool DNSName::canonCompare(const DNSName& rhs) const for(;;) { if(ourcount == 0 && rhscount != 0) return true; - if(ourcount == 0 && rhscount == 0) - return false; - if(ourcount !=0 && rhscount == 0) + if(rhscount == 0) return false; ourcount--; rhscount--; @@ -235,12 +233,8 @@ struct SuffixMatchTree SuffixMatchTree(const std::string& name="", bool endNode_=false) : d_name(name), endNode(endNode_) {} - SuffixMatchTree(const SuffixMatchTree& rhs) + SuffixMatchTree(const SuffixMatchTree& rhs): d_name(rhs.d_name), children(rhs.children), endNode(rhs.endNode), d_value(rhs.d_value) { - d_name = rhs.d_name; - children = rhs.children; - endNode = rhs.endNode; - d_value = rhs.d_value; } std::string d_name; mutable std::set children; diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index dfee6c399..805600dfc 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -199,9 +199,8 @@ DNSRecordContent::zmakermap_t& DNSRecordContent::getZmakermap() return zmakermap; } -DNSRecord::DNSRecord(const DNSResourceRecord& rr) +DNSRecord::DNSRecord(const DNSResourceRecord& rr): d_name(rr.qname) { - d_name = rr.qname; d_type = rr.qtype.getCode(); d_ttl = rr.ttl; d_class = rr.qclass; diff --git a/pdns/iputils.hh b/pdns/iputils.hh index b80aa800f..1b8d7f843 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -349,9 +349,8 @@ public: d_bits=0; } - Netmask(const ComboAddress& network, uint8_t bits=0xff) + Netmask(const ComboAddress& network, uint8_t bits=0xff): d_network(network) { - d_network = network; d_network.sin4.sin_port=0; if(bits > 128) bits = (network.sin4.sin_family == AF_INET) ? 32 : 128; @@ -601,6 +600,7 @@ public: // see above. for(auto const& node: rhs._nodes) insert(node->first).second = node->second; + d_cleanup_tree = rhs.d_cleanup_tree; return *this; } -- 2.40.0