]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Formatting
authorFred Morcos <fred.morcos@open-xchange.com>
Fri, 4 Mar 2022 11:18:43 +0000 (12:18 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Tue, 15 Mar 2022 09:05:49 +0000 (10:05 +0100)
pdns/dnsparser.hh
pdns/misc.cc
pdns/misc.hh

index 12ec50622af18457032491727262b0d43dbdb81d..b8b612dc627e98d12a5650a912b2bbcb366ef363 100644 (file)
@@ -257,10 +257,11 @@ public:
     n2typemap_t::const_iterator iter = getN2Typemap().find(toUpper(name));
     if(iter != getN2Typemap().end())
       return iter->second.second;
-    
-    if (isUnknownType(name))
-      return (uint16_t) pdns_stou(name.substr(4));
-    
+
+    if (isUnknownType(name)) {
+      return (uint16_t)pdns_stou(name.substr(4));
+    }
+
     throw runtime_error("Unknown DNS type '"+name+"'");
   }
 
index 9b0e397a99b74cd6221e9d5b50f895f18f0e61a2..bb62fb40df94843e7c92a56057a08a5625f31341 100644 (file)
@@ -281,26 +281,30 @@ bool stripDomainSuffix(string *qname, const string &domain)
   return true;
 }
 
-static void parseService4(const string &descr, ServiceTuple &st)
+static void parseService4(const string& descr, ServiceTuple& st)
 {
-  vector<string>parts;
-  stringtok(parts,descr,":");
-  if(parts.empty())
-    throw PDNSException("Unable to parse '"+descr+"' as a service");
-  st.host=parts[0];
-  if(parts.size()>1)
-    st.port=pdns_stou(parts[1]);
+  vector<string> parts;
+  stringtok(parts, descr, ":");
+  if (parts.empty()) {
+    throw PDNSException("Unable to parse '" + descr + "' as a service");
+  }
+  st.host = parts[0];
+  if (parts.size() > 1) {
+    st.port = pdns_stou(parts[1]);
+  }
 }
 
-static void parseService6(const string &descr, ServiceTuple &st)
+static void parseService6(const string& descr, ServiceTuple& st)
 {
-  string::size_type pos=descr.find(']');
-  if(pos == string::npos)
-    throw PDNSException("Unable to parse '"+descr+"' as an IPv6 service");
+  string::size_type pos = descr.find(']');
+  if (pos == string::npos) {
+    throw PDNSException("Unable to parse '" + descr + "' as an IPv6 service");
+  }
 
-  st.host=descr.substr(1, pos-1);
-  if(pos + 2 < descr.length())
-    st.port=pdns_stou(descr.substr(pos+2));
+  st.host = descr.substr(1, pos - 1);
+  if (pos + 2 < descr.length()) {
+    st.port = pdns_stou(descr.substr(pos + 2));
+  }
 }
 
 void parseService(const string &descr, ServiceTuple &st)
@@ -1509,21 +1513,24 @@ gid_t strToGID(const string &str)
   return result;
 }
 
-unsigned int pdns_stou(const std::string& str, size_t * idx, int base)
+unsigned int pdns_stou(const std::string& str, size_t* idx, int base)
 {
-  if (str.empty()) return 0; // compatibility
+  if (str.empty()) {
+    return 0; // compatibility
+  }
+
   unsigned long result;
   try {
     result = std::stoul(str, idx, base);
   }
-  catch(std::invalid_argument& e) {
-    throw std::invalid_argument(string(e.what()) + "; (invalid argument during std::stoul); data was \""+str+"\"");
+  catch (std::invalid_argument& e) {
+    throw std::invalid_argument(string(e.what()) + "; (invalid argument during std::stoul); data was \"" + str + "\"");
   }
-  catch(std::out_of_range& e) {
-    throw std::out_of_range(string(e.what()) + "; (out of range during std::stoul); data was \""+str+"\"");
+  catch (std::out_of_range& e) {
+    throw std::out_of_range(string(e.what()) + "; (out of range during std::stoul); data was \"" + str + "\"");
   }
   if (result > std::numeric_limits<unsigned int>::max()) {
-    throw std::out_of_range("stoul returned result out of unsigned int range; data was \""+str+"\"");
+    throw std::out_of_range("stoul returned result out of unsigned int range; data was \"" + str + "\"");
   }
   return static_cast<unsigned int>(result);
 }
index 6d4346574898d3b277724fcfe8d61745ab2e893f..595f119b4321d9753780feca794672d469134145 100644 (file)
@@ -617,7 +617,7 @@ double DiffTime(const struct timeval& first, const struct timeval& second);
 uid_t strToUID(const string &str);
 gid_t strToGID(const string &str);
 
-unsigned int pdns_stou(const std::string& str, size_t * idx = 0, int base = 10);
+unsigned int pdns_stou(const std::string& str, size_t* idx = 0, int base = 10);
 
 bool isSettingThreadCPUAffinitySupported();
 int mapThreadToCPUList(pthread_t tid, const std::set<int>& cpus);