]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
[clang-tidy:array] in dns.cc/hh std::array instead of c array. 12095/head
authorAxel Viala <axel.viala@darnuria.eu>
Thu, 6 Oct 2022 11:30:59 +0000 (13:30 +0200)
committerAxel Viala <axel.viala@darnuria.eu>
Tue, 18 Oct 2022 20:26:06 +0000 (22:26 +0200)
pdns/auth-catalogzone.hh
pdns/dns.cc
pdns/dns.hh

index 26805e71f2dc38161f8dbfaab88cac05a32034ee..ffbb106952f647e27056e689bda39644511ededb 100644 (file)
@@ -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];
index 1f046000011d8abe4b609f3fc35676aaa7f83e9d..d9fb5096f88c213ff88e369c131bb5da12674fe9 100644 (file)
 #include <boost/assign/list_of.hpp>
 #include "dnsparser.hh"
 
-std::vector<std::string> 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<std::string, 24> 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<std::string, 10> 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<std::string> s_opcodes = { "Query", "IQuery", "Status", "3", "Notify", "Update" };
+  static const std::array<std::string, 6> s_opcodes = { "Query", "IQuery", "Status", "3", "Notify", "Update" };
 
   if (opcode >= s_opcodes.size()) {
     return std::to_string(opcode);
index 683f4d072b9bfe9e83446618b4d778013dc13db7..b784be15b109abd227467e4c83592e2bc9ef4abd 100644 (file)
@@ -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<std::string> rcodes_s;
+  const static std::array<std::string, 24> rcodes_s;
 };
 
 class ERCode