From: Charles-Henri Bruyand Date: Thu, 13 Dec 2018 13:54:52 +0000 (+0100) Subject: Perform initialization in initialization list instead of in constructor body X-Git-Tag: rec-4.2.0-alpha1~49^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a70e507c6b9b457653e43bb756d6876cbd839ce;p=pdns Perform initialization in initialization list instead of in constructor body --- diff --git a/pdns/backends/gsql/ssql.hh b/pdns/backends/gsql/ssql.hh index d3d2285d1..df71eb91f 100644 --- a/pdns/backends/gsql/ssql.hh +++ b/pdns/backends/gsql/ssql.hh @@ -32,9 +32,8 @@ class SSqlException { public: - SSqlException(const string &reason) + SSqlException(const string &reason) : d_reason(reason) { - d_reason=reason; } string txtReason() diff --git a/pdns/dnsbulktest.cc b/pdns/dnsbulktest.cc index 414068642..27a288173 100644 --- a/pdns/dnsbulktest.cc +++ b/pdns/dnsbulktest.cc @@ -77,10 +77,8 @@ struct SendReceive boost::array d_probs; - SendReceive(const std::string& remoteAddr, uint16_t port) + SendReceive(const std::string& remoteAddr, uint16_t port) : d_probs({{0.001,0.01, 0.025, 0.1, 0.25,0.5,0.75,0.9,0.975, 0.99,0.9999}}) { - boost::array tmp ={{0.001,0.01, 0.025, 0.1, 0.25,0.5,0.75,0.9,0.975, 0.99,0.9999}}; - d_probs = tmp; d_acc = new acc_t(boost::accumulators::tag::extended_p_square::probabilities=d_probs); // //d_acc = acc_t diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index c4ae2bac3..0be157419 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -283,9 +283,7 @@ enum class PrometheusMetricType: int { // Keeps additional information about metrics struct MetricDefinition { - MetricDefinition(PrometheusMetricType prometheusType, const std::string& description) { - this->prometheusType = prometheusType; - this->description = description; + MetricDefinition(PrometheusMetricType prometheusType, const std::string& description): description(description), prometheusType(prometheusType) { } MetricDefinition() = default; diff --git a/pdns/dnspacket.cc b/pdns/dnspacket.cc index b5fcdb51c..82b3689fc 100644 --- a/pdns/dnspacket.cc +++ b/pdns/dnspacket.cc @@ -93,45 +93,45 @@ uint16_t DNSPacket::getRemotePort() const return d_remote.sin4.sin_port; } -DNSPacket::DNSPacket(const DNSPacket &orig) +DNSPacket::DNSPacket(const DNSPacket &orig) : + d_socket(orig.d_socket), + d_remote(orig.d_remote), + d_dt(orig.d_dt), + d_compress(orig.d_compress), + d_tcp(orig.d_tcp), + qtype(orig.qtype), + qclass(orig.qclass), + qdomain(orig.qdomain), + qdomainwild(orig.qdomainwild), + qdomainzone(orig.qdomainzone), + d_maxreplylen(orig.d_maxreplylen), + d_wantsnsid(orig.d_wantsnsid), + d_anyLocal(orig.d_anyLocal), + d_eso(orig.d_eso), + d_haveednssubnet(orig.d_haveednssubnet), + d_haveednssection(orig.d_haveednssection), + d_ednsversion(orig.d_ednsversion), + d_ednsrcode(orig.d_ednsrcode), + d_dnssecOk(orig.d_dnssecOk), + d_rrs(orig.d_rrs), + + d_tsigkeyname(orig.d_tsigkeyname), + d_tsigprevious(orig.d_tsigprevious), + d_tsigtimersonly(orig.d_tsigtimersonly), + d_trc(orig.d_trc), + d_tsigsecret(orig.d_tsigsecret), + d_ednsRawPacketSizeLimit(orig.d_ednsRawPacketSizeLimit), + d_havetsig(orig.d_havetsig), + d_wrapped(orig.d_wrapped), + + d_rawpacket(orig.d_rawpacket), + d_tsig_algo(orig.d_tsig_algo), + d(orig.d), + + d_isQuery(orig.d_isQuery), + d_hash(orig.d_hash) { DLOG(g_log<<"DNSPacket copy constructor called!"<(new WebServer(listenAddress.toString(), listenAddress.getPort())); +IXFRDistWebServer::IXFRDistWebServer(const ComboAddress &listenAddress, const NetmaskGroup &acl) : + d_ws(std::unique_ptr(new WebServer(listenAddress.toString(), listenAddress.getPort()))) +{ d_ws->setACL(acl); d_ws->registerWebHandler("/metrics", boost::bind(&IXFRDistWebServer::getMetrics, this, _1, _2)); d_ws->bind(); diff --git a/pdns/misc.cc b/pdns/misc.cc index 196a4bcf4..8282997a5 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -446,9 +446,8 @@ DTime::DTime() d_set.tv_sec=d_set.tv_usec=0; } -DTime::DTime(const DTime &dt) +DTime::DTime(const DTime &dt) : d_set(dt.d_set) { - d_set=dt.d_set; } time_t DTime::time() diff --git a/pdns/misc.hh b/pdns/misc.hh index fcf3c6a51..f04d7bb72 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -470,10 +470,8 @@ private: class SimpleMatch { public: - SimpleMatch(const string &mask, bool caseFold = false) + SimpleMatch(const string &mask, bool caseFold = false): d_mask(mask), d_fold(caseFold) { - this->d_mask = mask; - this->d_fold = caseFold; } bool match(string::const_iterator mi, string::const_iterator mend, string::const_iterator vi, string::const_iterator vend) diff --git a/pdns/pdnsexception.hh b/pdns/pdnsexception.hh index 3f1e385d4..f820f5515 100644 --- a/pdns/pdnsexception.hh +++ b/pdns/pdnsexception.hh @@ -31,8 +31,8 @@ class PDNSException { public: - PDNSException(){reason="Unspecified";}; - PDNSException(string r){reason=r;}; + PDNSException() : reason("Unspecified") {}; + PDNSException(string r) : reason(r) {}; string reason; //! Print this to tell the user what went wrong }; diff --git a/pdns/pkcs11signers.cc b/pdns/pkcs11signers.cc index 55c933774..ebc51c6a4 100644 --- a/pdns/pkcs11signers.cc +++ b/pdns/pkcs11signers.cc @@ -217,12 +217,13 @@ class Pkcs11Slot { } public: - Pkcs11Slot(CK_FUNCTION_LIST* functions, const CK_SLOT_ID& slot) { + Pkcs11Slot(CK_FUNCTION_LIST* functions, const CK_SLOT_ID& slot) : + d_slot(slot), + d_functions(functions), + d_err(0), + d_logged_in(false) + { CK_TOKEN_INFO tokenInfo; - d_slot = slot; - d_functions = functions; - d_err = 0; - d_logged_in = false; pthread_mutex_init(&(this->d_m), NULL); Lock l(&d_m); @@ -768,14 +769,15 @@ std::shared_ptr Pkcs11Token::GetToken(const std::string& module, co return pkcs11_tokens[tidx]; } -Pkcs11Token::Pkcs11Token(const std::shared_ptr& slot, const std::string& label, const std::string& pub_label) { +Pkcs11Token::Pkcs11Token(const std::shared_ptr& slot, const std::string& label, const std::string& pub_label) : + d_bits(0), + d_slot(slot), + d_label(label), + d_pub_label(pub_label), + d_err(0), + d_loaded(false) +{ // open a session - this->d_bits = 0; - this->d_slot = slot; - this->d_label = label; - this->d_pub_label = pub_label; - this->d_err = 0; - this->d_loaded = false; if (this->d_slot->LoggedIn()) LoadAttributes(); } diff --git a/pdns/ssqlite3.cc b/pdns/ssqlite3.cc index 62b223ceb..860d25452 100644 --- a/pdns/ssqlite3.cc +++ b/pdns/ssqlite3.cc @@ -49,13 +49,14 @@ int pdns_sqlite3_clear_bindings(sqlite3_stmt *pStmt){ class SSQLite3Statement: public SSqlStatement { public: - SSQLite3Statement(SSQLite3 *db, bool dolog, const string& query) : d_prepared(false) + SSQLite3Statement(SSQLite3 *db, bool dolog, const string& query) : + d_prepared(false), + d_query(query), + d_dolog(dolog), + d_stmt(NULL), + d_rc(0), + d_db(db) { - this->d_query = query; - this->d_dolog = dolog; - d_stmt = NULL; - d_rc = 0; - d_db = db; } int name2idx(const string& name) { diff --git a/pdns/syncres.hh b/pdns/syncres.hh index cb2a44859..d9bbebf06 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -72,11 +72,8 @@ typedef map< template class Throttle : public boost::noncopyable { public: - Throttle() + Throttle() : d_limit(3), d_ttl(60), d_last_clean(time(0)) { - d_limit=3; - d_ttl=60; - d_last_clean=time(0); } struct entry @@ -967,7 +964,7 @@ private: class ImmediateServFailException { public: - ImmediateServFailException(string r){reason=r;}; + ImmediateServFailException(string r) : reason(r) {}; string reason; //! Print this to tell the user what went wrong }; diff --git a/pdns/webserver.cc b/pdns/webserver.cc index 71ac17730..979cc7085 100644 --- a/pdns/webserver.cc +++ b/pdns/webserver.cc @@ -321,10 +321,11 @@ catch(...) { g_log<& new_ptrs); static void makePtr(const DNSResourceRecord& rr, DNSResourceRecord* ptr); -AuthWebServer::AuthWebServer() +AuthWebServer::AuthWebServer() : + d_start(time(0)), + d_min10(0), + d_min5(0), + d_min1(0), + d_ws(nullptr), + d_tid(0) { - d_start=time(0); - d_min10=d_min5=d_min1=0; - d_ws = 0; - d_tid = 0; if(arg().mustDo("webserver") || arg().mustDo("api")) { d_ws = new WebServer(arg()["webserver-address"], arg().asNum("webserver-port")); d_ws->setApiKey(arg()["api-key"]); diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index 7a850ffc8..fc859c57a 100644 --- a/pdns/zoneparser-tng.cc +++ b/pdns/zoneparser-tng.cc @@ -46,13 +46,11 @@ ZoneParserTNG::ZoneParserTNG(const string& fname, const DNSName& zname, const st } ZoneParserTNG::ZoneParserTNG(const vector zonedata, const DNSName& zname): - d_zonename(zname), d_defaultttl(3600), - d_templatecounter(0), d_templatestop(0), - d_templatestep(0), d_havedollarttl(false) + d_zonename(zname), d_zonedata(zonedata), d_defaultttl(3600), + d_templatecounter(0), d_templatestop(0), d_templatestep(0), + d_havedollarttl(false), d_fromfile(false) { - d_zonedata = zonedata; d_zonedataline = d_zonedata.begin(); - d_fromfile = false; } void ZoneParserTNG::stackFile(const std::string& fname)