From: Remi Gacogne Date: Tue, 27 Mar 2018 12:26:38 +0000 (+0200) Subject: dnsdist: Pass shared pointers by reference whenever possible X-Git-Tag: dnsdist-1.3.0~7^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3b1a1efbc9c1f8907cfd8ffc1dd6eaa0e56bd4b;p=pdns dnsdist: Pass shared pointers by reference whenever possible --- diff --git a/pdns/dnscrypt.cc b/pdns/dnscrypt.cc index 1f7456348..f81263c09 100644 --- a/pdns/dnscrypt.cc +++ b/pdns/dnscrypt.cc @@ -713,7 +713,7 @@ int DNSCryptQuery::encryptResponse(char* response, uint16_t responseLen, uint16_ return res; } -int DNSCryptContext::encryptQuery(char* query, uint16_t queryLen, uint16_t querySize, const unsigned char clientPublicKey[DNSCRYPT_PUBLIC_KEY_SIZE], const DNSCryptPrivateKey& clientPrivateKey, const unsigned char clientNonce[DNSCRYPT_NONCE_SIZE / 2], bool tcp, uint16_t* encryptedResponseLen, const std::shared_ptr cert) const +int DNSCryptContext::encryptQuery(char* query, uint16_t queryLen, uint16_t querySize, const unsigned char clientPublicKey[DNSCRYPT_PUBLIC_KEY_SIZE], const DNSCryptPrivateKey& clientPrivateKey, const unsigned char clientNonce[DNSCRYPT_NONCE_SIZE / 2], bool tcp, uint16_t* encryptedResponseLen, const std::shared_ptr& cert) const { assert(query != nullptr); assert(queryLen > 0); diff --git a/pdns/dnscrypt.hh b/pdns/dnscrypt.hh index fea11f0c7..acdad413b 100644 --- a/pdns/dnscrypt.hh +++ b/pdns/dnscrypt.hh @@ -152,7 +152,7 @@ struct DNSCryptCertificatePair class DNSCryptQuery { public: - DNSCryptQuery(std::shared_ptr ctx): d_ctx(ctx) + DNSCryptQuery(const std::shared_ptr& ctx): d_ctx(ctx) { } ~DNSCryptQuery(); @@ -182,7 +182,7 @@ public: return d_encrypted; } - void setCertificatePair(std::shared_ptr pair) + void setCertificatePair(const std::shared_ptr& pair) { d_pair = pair; } @@ -213,7 +213,7 @@ private: std::shared_ptr d_pair{nullptr}; uint16_t d_id{0}; uint16_t d_len{0}; - uint16_t d_paddedLen; + uint16_t d_paddedLen{0}; bool d_encrypted{false}; bool d_valid{false}; @@ -246,7 +246,7 @@ public: std::vector> getCertificates() { return certs; }; const DNSName& getProviderName() const { return providerName; } - int encryptQuery(char* query, uint16_t queryLen, uint16_t querySize, const unsigned char clientPublicKey[DNSCRYPT_PUBLIC_KEY_SIZE], const DNSCryptPrivateKey& clientPrivateKey, const unsigned char clientNonce[DNSCRYPT_NONCE_SIZE / 2], bool tcp, uint16_t* encryptedResponseLen, const std::shared_ptr cert) const; + int encryptQuery(char* query, uint16_t queryLen, uint16_t querySize, const unsigned char clientPublicKey[DNSCRYPT_PUBLIC_KEY_SIZE], const DNSCryptPrivateKey& clientPrivateKey, const unsigned char clientNonce[DNSCRYPT_NONCE_SIZE / 2], bool tcp, uint16_t* encryptedResponseLen, const std::shared_ptr& cert) const; bool magicMatchesAPublicKey(DNSCryptQuery& query, time_t now); void getCertificateResponse(time_t now, const DNSName& qname, uint16_t qid, std::vector& response); diff --git a/pdns/dnsdist-dynbpf.hh b/pdns/dnsdist-dynbpf.hh index 3fed6f18c..321e930be 100644 --- a/pdns/dnsdist-dynbpf.hh +++ b/pdns/dnsdist-dynbpf.hh @@ -35,7 +35,7 @@ class DynBPFFilter { public: - DynBPFFilter(std::shared_ptr bpf): d_bpf(bpf) + DynBPFFilter(std::shared_ptr& bpf): d_bpf(bpf) { } ~DynBPFFilter() diff --git a/pdns/dnsdist-lua-actions.cc b/pdns/dnsdist-lua-actions.cc index fa937924a..7df6aa8df 100644 --- a/pdns/dnsdist-lua-actions.cc +++ b/pdns/dnsdist-lua-actions.cc @@ -651,7 +651,7 @@ public: class DnstapLogAction : public DNSAction, public boost::noncopyable { public: - DnstapLogAction(const std::string& identity, std::shared_ptr logger, boost::optional > alterFunc): d_identity(identity), d_logger(logger), d_alterFunc(alterFunc) + DnstapLogAction(const std::string& identity, std::shared_ptr& logger, boost::optional > alterFunc): d_identity(identity), d_logger(logger), d_alterFunc(alterFunc) { } DNSAction::Action operator()(DNSQuestion* dq, string* ruleresult) const override @@ -683,7 +683,7 @@ private: class RemoteLogAction : public DNSAction, public boost::noncopyable { public: - RemoteLogAction(std::shared_ptr logger, boost::optional > alterFunc): d_logger(logger), d_alterFunc(alterFunc) + RemoteLogAction(std::shared_ptr& logger, boost::optional > alterFunc): d_logger(logger), d_alterFunc(alterFunc) { } DNSAction::Action operator()(DNSQuestion* dq, string* ruleresult) const override @@ -740,7 +740,7 @@ private: class TagAction : public DNSAction { public: - TagAction(const std::string tag, const std::string value): d_tag(tag), d_value(value) + TagAction(const std::string& tag, const std::string& value): d_tag(tag), d_value(value) { } DNSAction::Action operator()(DNSQuestion* dq, string* ruleresult) const override @@ -765,7 +765,7 @@ private: class DnstapLogResponseAction : public DNSResponseAction, public boost::noncopyable { public: - DnstapLogResponseAction(const std::string& identity, std::shared_ptr logger, boost::optional > alterFunc): d_identity(identity), d_logger(logger), d_alterFunc(alterFunc) + DnstapLogResponseAction(const std::string& identity, std::shared_ptr& logger, boost::optional > alterFunc): d_identity(identity), d_logger(logger), d_alterFunc(alterFunc) { } DNSResponseAction::Action operator()(DNSResponse* dr, string* ruleresult) const override @@ -799,7 +799,7 @@ private: class RemoteLogResponseAction : public DNSResponseAction, public boost::noncopyable { public: - RemoteLogResponseAction(std::shared_ptr logger, boost::optional > alterFunc, bool includeCNAME): d_logger(logger), d_alterFunc(alterFunc), d_includeCNAME(includeCNAME) + RemoteLogResponseAction(std::shared_ptr& logger, boost::optional > alterFunc, bool includeCNAME): d_logger(logger), d_alterFunc(alterFunc), d_includeCNAME(includeCNAME) { } DNSResponseAction::Action operator()(DNSResponse* dr, string* ruleresult) const override @@ -901,7 +901,7 @@ private: class TagResponseAction : public DNSResponseAction { public: - TagResponseAction(const std::string tag, const std::string value): d_tag(tag), d_value(value) + TagResponseAction(const std::string& tag, const std::string& value): d_tag(tag), d_value(value) { } DNSResponseAction::Action operator()(DNSResponse* dr, string* ruleresult) const override diff --git a/pdns/dnsdist-lua-rules.cc b/pdns/dnsdist-lua-rules.cc index 9ae95466d..66d66d71c 100644 --- a/pdns/dnsdist-lua-rules.cc +++ b/pdns/dnsdist-lua-rules.cc @@ -826,7 +826,7 @@ private: class TagRule : public DNSRule { public: - TagRule(std::string tag, boost::optional value) : d_value(value), d_tag(tag) + TagRule(const std::string& tag, boost::optional value) : d_value(value), d_tag(tag) { } bool matches(const DNSQuestion* dq) const override diff --git a/pdns/dnsdist-lua.hh b/pdns/dnsdist-lua.hh index 19c5f3965..bf3a921be 100644 --- a/pdns/dnsdist-lua.hh +++ b/pdns/dnsdist-lua.hh @@ -25,7 +25,7 @@ class LuaAction : public DNSAction { public: typedef std::function >(DNSQuestion* dq)> func_t; - LuaAction(LuaAction::func_t func) : d_func(func) + LuaAction(LuaAction::func_t& func) : d_func(func) {} Action operator()(DNSQuestion* dq, string* ruleresult) const override; string toString() const override @@ -40,7 +40,7 @@ class LuaResponseAction : public DNSResponseAction { public: typedef std::function >(DNSResponse* dr)> func_t; - LuaResponseAction(LuaResponseAction::func_t func) : d_func(func) + LuaResponseAction(LuaResponseAction::func_t& func) : d_func(func) {} Action operator()(DNSResponse* dr, string* ruleresult) const override; string toString() const override diff --git a/pdns/dnsdist-snmp.cc b/pdns/dnsdist-snmp.cc index ec9683f45..f04445183 100644 --- a/pdns/dnsdist-snmp.cc +++ b/pdns/dnsdist-snmp.cc @@ -367,7 +367,7 @@ static int backendStatTable_handler(netsnmp_mib_handler* handler, } #endif /* HAVE_NET_SNMP */ -bool DNSDistSNMPAgent::sendBackendStatusChangeTrap(const std::shared_ptr dss) +bool DNSDistSNMPAgent::sendBackendStatusChangeTrap(const std::shared_ptr& dss) { #ifdef HAVE_NET_SNMP const string backendAddress = dss->remote.toStringWithPort(); diff --git a/pdns/dnsdist-snmp.hh b/pdns/dnsdist-snmp.hh index bced61aab..b04518286 100644 --- a/pdns/dnsdist-snmp.hh +++ b/pdns/dnsdist-snmp.hh @@ -13,7 +13,7 @@ class DNSDistSNMPAgent: public SNMPAgent { public: DNSDistSNMPAgent(const std::string& name, const std::string& masterSocket); - bool sendBackendStatusChangeTrap(const std::shared_ptr); + bool sendBackendStatusChangeTrap(const std::shared_ptr&); bool sendCustomTrap(const std::string& reason); bool sendDNSTrap(const DNSQuestion&, const std::string& reason=""); }; diff --git a/pdns/dnsdistdist/tcpiohandler.cc b/pdns/dnsdistdist/tcpiohandler.cc index f2dddc98b..4f8d11e12 100644 --- a/pdns/dnsdistdist/tcpiohandler.cc +++ b/pdns/dnsdistdist/tcpiohandler.cc @@ -613,7 +613,7 @@ class GnuTLSConnection: public TLSConnection { public: - GnuTLSConnection(int socket, unsigned int timeout, const gnutls_certificate_credentials_t creds, const gnutls_priority_t priorityCache, std::shared_ptr ticketsKey): d_ticketsKey(ticketsKey) + GnuTLSConnection(int socket, unsigned int timeout, const gnutls_certificate_credentials_t creds, const gnutls_priority_t priorityCache, std::shared_ptr& ticketsKey): d_ticketsKey(ticketsKey) { d_socket = socket;