]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Cleanup rcodes enums: base one is 8 bit unisgned, extended one 16 bit unsigned 12710/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 31 Mar 2023 11:36:04 +0000 (13:36 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 31 Mar 2023 11:39:36 +0000 (13:39 +0200)
pdns/dns.cc
pdns/dns.hh

index d9fb5096f88c213ff88e369c131bb5da12674fe9..99bbd72aa65e8749e66ee8237914427ab80ba681 100644 (file)
@@ -71,8 +71,9 @@ static const std::array<std::string, 10> rcodes_short_s =  {
 };
 
 std::string RCode::to_s(uint8_t rcode) {
-  if (rcode > 0xF)
+  if (rcode > 0xF) {
     return std::string("ErrOutOfRange");
+  }
   return ERCode::to_s(rcode);
 }
 
@@ -83,9 +84,10 @@ std::string RCode::to_short_s(uint8_t rcode) {
   return rcodes_short_s.at(rcode);
 }
 
-std::string ERCode::to_s(uint8_t rcode) {
-  if (rcode > RCode::rcodes_s.size()-1)
+std::string ERCode::to_s(uint16_t rcode) {
+  if (rcode >= RCode::rcodes_s.size()) {
     return std::string("Err#")+std::to_string(rcode);
+  }
   return RCode::rcodes_s.at(rcode);
 }
 
index ef44cf813d0b6c6389db733d9da92e5c430761c9..7ceda1eeecc7c7d20cf8a2ecdd80dc62c5ae6dc4 100644 (file)
@@ -32,7 +32,7 @@ struct DNSRecord;
 class RCode
 {
 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};
+  enum rcodes_ : uint8_t { 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);
   const static std::array<std::string, 24> rcodes_s;
@@ -41,8 +41,8 @@ public:
 class ERCode
 {
 public:
-  enum rcodes_ { BADVERS=16, BADSIG=16, BADKEY=17, BADTIME=18, BADMODE=19, BADNAME=20, BADALG=21, BADTRUNC=22, BADCOOKIE=23 };
-  static std::string to_s(uint8_t rcode);
+  enum rcodes_ : uint16_t { BADVERS=16, BADSIG=16, BADKEY=17, BADTIME=18, BADMODE=19, BADNAME=20, BADALG=21, BADTRUNC=22, BADCOOKIE=23 };
+  static std::string to_s(uint16_t rcode);
 };
 
 class Opcode