From: Axel Viala Date: Thu, 6 Oct 2022 11:30:59 +0000 (+0200) Subject: [clang-tidy:array] in dns.cc/hh std::array instead of c array. X-Git-Tag: dnsdist-1.8.0-rc1~225^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=251aedda2d9cea712d5d2910ba62bf13518ff04f;p=thirdparty%2Fpdns.git [clang-tidy:array] in dns.cc/hh std::array instead of c array. --- diff --git a/pdns/auth-catalogzone.hh b/pdns/auth-catalogzone.hh index 26805e71f2..ffbb106952 100644 --- a/pdns/auth-catalogzone.hh +++ b/pdns/auth-catalogzone.hh @@ -41,7 +41,7 @@ public: Consumer }; - static const char* getTypeString(enum CatalogType type) + static constexpr const char* getTypeString(enum CatalogType type) { const char* types[] = {"none", "producer", "consumer"}; return types[type]; diff --git a/pdns/dns.cc b/pdns/dns.cc index 1f04600001..d9fb5096f8 100644 --- a/pdns/dns.cc +++ b/pdns/dns.cc @@ -30,32 +30,32 @@ #include #include "dnsparser.hh" -std::vector RCode::rcodes_s = boost::assign::list_of - ("No Error") - ("Form Error") - ("Server Failure") - ("Non-Existent domain") - ("Not Implemented") - ("Query Refused") - ("Name Exists when it should not") - ("RR Set Exists when it should not") - ("RR Set that should exist does not") - ("Server Not Authoritative for zone / Not Authorized") - ("Name not contained in zone") - ("Err#11") - ("Err#12") - ("Err#13") - ("Err#14") - ("Err#15") // Last non-extended RCode - ("Bad OPT Version / TSIG Signature Failure") - ("Key not recognized") - ("Signature out of time window") - ("Bad TKEY Mode") - ("Duplicate key name") - ("Algorithm not supported") - ("Bad Truncation") - ("Bad/missing Server Cookie") -; +const std::array RCode::rcodes_s = { + "No Error", + "Form Error", + "Server Failure", + "Non-Existent domain", + "Not Implemented", + "Query Refused", + "Name Exists when it should not", + "RR Set Exists when it should not", + "RR Set that should exist does not", + "Server Not Authoritative for zone / Not Authorized", + "Name not contained in zone", + "Err#11", + "Err#12", + "Err#13", + "Err#14", + "Err#15", // Last non-extended RCode + "Bad OPT Version / TSIG Signature Failure", + "Key not recognized", + "Signature out of time window", + "Bad TKEY Mode", + "Duplicate key name", + "Algorithm not supported", + "Bad Truncation", + "Bad/missing Server Cookie" +}; static const std::array rcodes_short_s = { "noerror", @@ -86,11 +86,11 @@ std::string RCode::to_short_s(uint8_t rcode) { std::string ERCode::to_s(uint8_t rcode) { if (rcode > RCode::rcodes_s.size()-1) return std::string("Err#")+std::to_string(rcode); - return RCode::rcodes_s[rcode]; + return RCode::rcodes_s.at(rcode); } std::string Opcode::to_s(uint8_t opcode) { - static const std::vector s_opcodes = { "Query", "IQuery", "Status", "3", "Notify", "Update" }; + static const std::array s_opcodes = { "Query", "IQuery", "Status", "3", "Notify", "Update" }; if (opcode >= s_opcodes.size()) { return std::to_string(opcode); diff --git a/pdns/dns.hh b/pdns/dns.hh index 683f4d072b..b784be15b1 100644 --- a/pdns/dns.hh +++ b/pdns/dns.hh @@ -35,7 +35,7 @@ public: enum rcodes_ { NoError=0, FormErr=1, ServFail=2, NXDomain=3, NotImp=4, Refused=5, YXDomain=6, YXRRSet=7, NXRRSet=8, NotAuth=9, NotZone=10}; static std::string to_s(uint8_t rcode); static std::string to_short_s(uint8_t rcode); - static std::vector rcodes_s; + const static std::array rcodes_s; }; class ERCode