From 42225bb43bb91812e8d85bfc745ac8e5cf3dafa4 Mon Sep 17 00:00:00 2001 From: Charles-Henri Bruyand Date: Thu, 18 Jan 2024 11:44:36 +0100 Subject: [PATCH] dnsdist: revert some clang-tidy related changes --- pdns/dnsdist-lua-actions.cc | 24 ++++++++++++++++-------- pdns/dnsdist-protobuf.hh | 10 ++++++---- pdns/dnsname.cc | 2 +- pdns/dnsname.hh | 2 +- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/pdns/dnsdist-lua-actions.cc b/pdns/dnsdist-lua-actions.cc index 22229b6dcb..22077fcf34 100644 --- a/pdns/dnsdist-lua-actions.cc +++ b/pdns/dnsdist-lua-actions.cc @@ -327,8 +327,10 @@ public: } private: - std::string d_pool; - bool d_stopProcessing; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const std::string d_pool; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const bool d_stopProcessing; }; class QPSPoolAction : public DNSAction @@ -355,8 +357,10 @@ public: private: mutable LockGuarded d_qps; - std::string d_pool; - bool d_stopProcessing; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const std::string d_pool; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const bool d_stopProcessing; }; class RCodeAction : public DNSAction @@ -747,8 +751,10 @@ private: }; static std::atomic s_functionsCounter; static thread_local std::map t_perThreadStates; - std::string d_functionCode; - uint64_t d_functionID; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const std::string d_functionCode; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const uint64_t d_functionID; }; std::atomic LuaFFIPerThreadAction::s_functionsCounter = 0; @@ -869,8 +875,10 @@ private: static std::atomic s_functionsCounter; static thread_local std::map t_perThreadStates; - std::string d_functionCode; - uint64_t d_functionID; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const std::string d_functionCode; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const uint64_t d_functionID; }; std::atomic LuaFFIPerThreadResponseAction::s_functionsCounter = 0; diff --git a/pdns/dnsdist-protobuf.hh b/pdns/dnsdist-protobuf.hh index 86ec100331..c2dee817da 100644 --- a/pdns/dnsdist-protobuf.hh +++ b/pdns/dnsdist-protobuf.hh @@ -87,7 +87,6 @@ private: }; std::unordered_map d_metaTags; - // FIXME wondering if the cost of moving to a shared_ptr would be that bad // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) const DNSQuestion& d_dq; const DNSResponse* d_dr{nullptr}; @@ -127,9 +126,12 @@ class ProtoBufMetaKey struct KeyTypeDescription { - std::string d_name; - Type d_type; - std::function(const DNSQuestion&, const std::string&, uint8_t)> d_func; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const std::string d_name; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const Type d_type; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) + const std::function(const DNSQuestion&, const std::string&, uint8_t)> d_func; bool d_prefix{false}; bool d_caseSensitive{true}; bool d_numeric{false}; diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index 21008f38fe..25a90078a8 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -100,7 +100,7 @@ DNSName::DNSName(const std::string_view sw) } -DNSName::DNSName(const char* pos, size_t len, size_t offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed, uint16_t minOffset) +DNSName::DNSName(const char* pos, int len, int offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed, uint16_t minOffset) { if (offset >= len) throw std::range_error("Trying to read past the end of the buffer ("+std::to_string(offset)+ " >= "+std::to_string(len)+")"); diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index dbdc2ac2c3..9b9692f51e 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -100,7 +100,7 @@ public: DNSName(DNSName&& a) = default; explicit DNSName(std::string_view sw); //!< Constructs from a human formatted, escaped presentation - DNSName(const char* pos, size_t len, size_t offset, bool uncompress, uint16_t* qtype = nullptr, uint16_t* qclass = nullptr, unsigned int* consumed = nullptr, uint16_t minOffset = 0); //!< Construct from a DNS Packet, taking the first question if offset=12. If supplied, consumed is set to the number of bytes consumed from the packet, which will not be equal to the wire length of the resulting name in case of compression. + DNSName(const char* p, int len, int offset, bool uncompress, uint16_t* qtype = nullptr, uint16_t* qclass = nullptr, unsigned int* consumed = nullptr, uint16_t minOffset = 0); //!< Construct from a DNS Packet, taking the first question if offset=12. If supplied, consumed is set to the number of bytes consumed from the packet, which will not be equal to the wire length of the resulting name in case of compression. bool isPartOf(const DNSName& rhs) const; //!< Are we part of the rhs name? Note that name.isPartOf(name). inline bool operator==(const DNSName& rhs) const; //!< DNS-native comparison (case insensitive) - empty compares to empty -- 2.47.2