]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Use '\0' for (char) 0 and ref for string_view argument
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 30 Nov 2022 13:26:18 +0000 (14:26 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 30 Nov 2022 13:26:18 +0000 (14:26 +0100)
pdns/dnsname.cc
pdns/dnsname.hh

index db09f6c4079459d0e711623544e7dc10394fcad9..dd3c1ccef51e42b1252a11e67fdf3630e8a33589 100644 (file)
@@ -53,13 +53,13 @@ void DNSName::throwSafeRangeError(const std::string& msg, const char* buf, size_
   throw std::range_error(msg + label + dots);
 }
 
-DNSName::DNSName(const std::string_view sw)
+DNSName::DNSName(const std::string_view& sw)
 {
   const char* p = sw.data();
   size_t length = sw.length();
 
   if(length == 0 || (length == 1 && p[0]=='.')) {
-    d_storage.assign(1, (char)0);
+    d_storage.assign(1, '\0');
   } else {
     if(!std::memchr(p, '\\', length)) {
       unsigned char lenpos=0;
@@ -71,7 +71,7 @@ DNSName::DNSName(const std::string_view sw)
         lenpos = d_storage.size();
         if(*iter=='.')
           throwSafeRangeError("Found . in wrong position in DNSName: ", p, length);
-        d_storage.append(1, (char)0);
+        d_storage.append(1, '\0');
         labellen=0;
         auto begiter=iter;
         for(; iter != pend && *iter!='.'; ++iter) {
@@ -88,7 +88,7 @@ DNSName::DNSName(const std::string_view sw)
 
         d_storage[lenpos]=labellen;
       }
-      d_storage.append(1, (char)0);
+      d_storage.append(1, '\0');
     }
     else {
       d_storage=segmentDNSNameRaw(p, length);
index 90c752be3fa493a53a5c66cfcf7a355c473021e2..18b1e271597367ac9174298cf9ebd20a0cf34c82 100644 (file)
@@ -99,7 +99,7 @@ public:
   DNSName(const DNSName& a) = default;
   DNSName(DNSName&& a) = default;
 
-  explicit DNSName(const std::string_view sw); //!< Constructs from a human formatted, escaped presentation
+  explicit DNSName(const std::string_view& sw); //!< Constructs from a human formatted, escaped presentation
   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).