From f238ce64f7a0ca98d486d347160b5a948ab662ae Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 30 Sep 2019 11:46:13 +0200 Subject: [PATCH] Cleanup copy constructor/assignment op "rule-of-2" violations. --- pdns/dnsname.hh | 11 +++++++++++ pdns/dnspacket.cc | 43 ----------------------------------------- pdns/dnspacket.hh | 3 ++- pdns/misc.cc | 4 ---- pdns/misc.hh | 3 ++- pdns/resolve-context.hh | 13 ++++--------- pdns/syncres.hh | 7 +++---- 7 files changed, 22 insertions(+), 62 deletions(-) diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index 68d17f7c4..da6c4de46 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -242,6 +242,17 @@ struct SuffixMatchTree d_value = rhs.d_value; } } + SuffixMatchTree & operator=(const SuffixMatchTree &rhs) + { + d_name = rhs.d_name; + children = rhs.children; + endNode = rhs.endNode; + if (endNode) { + d_value = rhs.d_value; + } + return *this; + } + std::string d_name; mutable std::set children; mutable bool endNode; diff --git a/pdns/dnspacket.cc b/pdns/dnspacket.cc index 37d142493..980770ff7 100644 --- a/pdns/dnspacket.cc +++ b/pdns/dnspacket.cc @@ -77,49 +77,6 @@ uint16_t DNSPacket::getRemotePort() const return d_remote.sin4.sin_port; } -DNSPacket::DNSPacket(const DNSPacket &orig) : - d_anyLocal(orig.d_anyLocal), - d_dt(orig.d_dt), - qdomain(orig.qdomain), - qdomainwild(orig.qdomainwild), - qdomainzone(orig.qdomainzone), - - d(orig.d), - d_trc(orig.d_trc), - d_remote(orig.d_remote), - d_tsig_algo(orig.d_tsig_algo), - - d_ednsRawPacketSizeLimit(orig.d_ednsRawPacketSizeLimit), - qclass(orig.qclass), - qtype(orig.qtype), - d_tcp(orig.d_tcp), - d_dnssecOk(orig.d_dnssecOk), - d_havetsig(orig.d_havetsig), - - d_tsigsecret(orig.d_tsigsecret), - d_tsigkeyname(orig.d_tsigkeyname), - d_tsigprevious(orig.d_tsigprevious), - d_rrs(orig.d_rrs), - d_rawpacket(orig.d_rawpacket), - d_eso(orig.d_eso), - d_maxreplylen(orig.d_maxreplylen), - d_socket(orig.d_socket), - d_hash(orig.d_hash), - d_ednsrcode(orig.d_ednsrcode), - d_ednsversion(orig.d_ednsversion), - - d_wrapped(orig.d_wrapped), - d_compress(orig.d_compress), - d_tsigtimersonly(orig.d_tsigtimersonly), - d_wantsnsid(orig.d_wantsnsid), - d_haveednssubnet(orig.d_haveednssubnet), - d_haveednssection(orig.d_haveednssection), - - d_isQuery(orig.d_isQuery) -{ - DLOG(g_log<<"DNSPacket copy constructor called!"<d_initialRequestId = ctx.d_initialRequestId; -#endif -#ifdef HAVE_FSTRM - this->d_auth = ctx.d_auth; -#endif - } + + ResolveContext(const ResolveContext& ctx) = delete; + ResolveContext & operator=(const ResolveContext&) = delete; + #ifdef HAVE_PROTOBUF boost::optional d_initialRequestId; #endif diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 02d648363..728a067bb 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -163,10 +163,9 @@ public: d_lastget=d_last; } - DecayingEwma(const DecayingEwma& orig) : d_last(orig.d_last), d_lastget(orig.d_lastget), d_val(orig.d_val), d_needinit(orig.d_needinit) - { - } - + DecayingEwma(const DecayingEwma& orig) = delete; + DecayingEwma & operator=(const DecayingEwma& orig) = delete; + void submit(int val, const struct timeval* tv) { struct timeval now=*tv; -- 2.40.0