]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Replace itoa() with std::to_string() 12064/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 5 Oct 2022 13:16:13 +0000 (15:16 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 24 Oct 2022 09:52:47 +0000 (11:52 +0200)
16 files changed:
.github/actions/spell-check/allow.txt
modules/gmysqlbackend/smysql.cc
modules/pipebackend/coprocess.cc
modules/pipebackend/pipebackend.cc
modules/remotebackend/pipeconnector.cc
pdns/arguments.cc
pdns/auth-main.cc
pdns/backends/gsql/gsqlbackend.cc
pdns/bindparser.yy
pdns/dynhandler.cc
pdns/misc.cc
pdns/misc.hh
pdns/qtype.cc
pdns/resolver.cc
pdns/rfc2136handler.cc
pdns/syncres.hh

index 1300aa6cff090a5155e5b01f61654e63a3a37ac5..bde902cd4e845a27842bb52019e4215648ab6517 100644 (file)
@@ -3826,7 +3826,6 @@ uhi
 uhry
 uintptr
 uio
-uitoa
 ulddquehrj
 ulen
 ulong
index 8b3c80bbc55623f92e413f6cd22a09e09e6593bd..a25f8f4c2cb02ca7c7a8228e1bc2b3f48b473a9f 100644 (file)
@@ -562,7 +562,7 @@ void SMySQL::execute(const string& query)
 
   int err;
   if ((err = mysql_query(&d_db, query.c_str())))
-    throw sPerrorException("Failed to execute mysql_query '" + query + "' Err=" + itoa(err));
+    throw sPerrorException("Failed to execute mysql_query '" + query + "' Err=" + std::to_string(err));
 }
 
 void SMySQL::startTransaction()
index 92c15f23e90c7f6766d13d8c5b086e6b586592ed..ac2c350ee506a5611d21ba5067b019e652f437d6 100644 (file)
@@ -121,15 +121,15 @@ void CoProcess::checkStatus()
   int status;
   int ret = waitpid(d_pid, &status, WNOHANG);
   if (ret < 0)
-    throw PDNSException("Unable to ascertain status of coprocess " + itoa(d_pid) + " from " + itoa(getpid()) + ": " + string(strerror(errno)));
+    throw PDNSException("Unable to ascertain status of coprocess " + std::to_string(d_pid) + " from " + std::to_string(getpid()) + ": " + string(strerror(errno)));
   else if (ret) {
     if (WIFEXITED(status)) {
       int exitStatus = WEXITSTATUS(status);
-      throw PDNSException("Coprocess exited with code " + itoa(exitStatus));
+      throw PDNSException("Coprocess exited with code " + std::to_string(exitStatus));
     }
     if (WIFSIGNALED(status)) {
       int sig = WTERMSIG(status);
-      string reason = "CoProcess died on receiving signal " + itoa(sig);
+      string reason = "CoProcess died on receiving signal " + std::to_string(sig);
 #ifdef WCOREDUMP
       if (WCOREDUMP(status))
         reason += ". Dumped core";
index 0f3dcbf5a97e1fac4736e565ddc5be20a416763b..fa94ea2f75e5325f93d1cf1887f983d4976e733d 100644 (file)
@@ -216,7 +216,7 @@ bool PipeBackend::list(const DNSName& target, int inZoneId, bool include_disable
   catch (PDNSException& ae) {
     g_log << Logger::Error << kBackendId << " Error from coprocess: " << ae.reason << endl;
   }
-  d_qname = DNSName(itoa(inZoneId)); // why do we store a number here??
+  d_qname = DNSName(std::to_string(inZoneId)); // why do we store a number here??
   return true;
 }
 
index 5d563acc0adccc29677f9b8ca8e8345383e676f9..e6f3a5da8e2ad88893750dbdd3a9b0ffb5187135 100644 (file)
@@ -187,15 +187,15 @@ bool PipeConnector::checkStatus()
   int status;
   int ret = waitpid(d_pid, &status, WNOHANG);
   if (ret < 0)
-    throw PDNSException("Unable to ascertain status of coprocess " + itoa(d_pid) + " from " + itoa(getpid()) + ": " + string(strerror(errno)));
+    throw PDNSException("Unable to ascertain status of coprocess " + std::to_string(d_pid) + " from " + std::to_string(getpid()) + ": " + string(strerror(errno)));
   else if (ret) {
     if (WIFEXITED(status)) {
       int exitStatus = WEXITSTATUS(status);
-      throw PDNSException("Coprocess exited with code " + itoa(exitStatus));
+      throw PDNSException("Coprocess exited with code " + std::to_string(exitStatus));
     }
     if (WIFSIGNALED(status)) {
       int sig = WTERMSIG(status);
-      string reason = "CoProcess died on receiving signal " + itoa(sig);
+      string reason = "CoProcess died on receiving signal " + std::to_string(sig);
 #ifdef WCOREDUMP
       if (WCOREDUMP(status))
         reason += ". Dumped core";
index 739b404a38d64201c3c25b54a710193f7a0c99a2..7f9f9b558c10dd6368d322da63dfb843c63c0a44 100644 (file)
@@ -474,7 +474,7 @@ bool ArgvMap::parseFile(const char* fname, const string& arg, bool lax)
   string line;
   string pline;
 
-  ifstream configFileStream(fname);
+  std::ifstream configFileStream(fname);
   if (!configFileStream) {
     return false;
   }
index f974da3002e97681ba75d39edb531646292c278c..0c4661c7d901ead05146f85d2825a67221a7c4fd 100644 (file)
@@ -1113,7 +1113,7 @@ static int guardian(int argc, char** argv)
           // execute some kind of ping here
           if (DLQuitPlease())
             takedown(1); // needs a parameter..
-          setStatus("Child running on pid " + itoa(pid));
+          setStatus("Child running on pid " + std::to_string(pid));
           sleep(1);
         }
       }
@@ -1130,7 +1130,7 @@ static int guardian(int argc, char** argv)
           g_log << Logger::Error << "Child requested a stop, exiting" << endl;
           exit(1);
         }
-        setStatus("Child died with code " + itoa(ret));
+        setStatus("Child died with code " + std::to_string(ret));
         g_log << Logger::Error << "Our pdns instance exited with code " << ret << ", respawning" << endl;
 
         sleep(1);
@@ -1138,7 +1138,7 @@ static int guardian(int argc, char** argv)
       }
       if (WIFSIGNALED(status)) {
         int sig = WTERMSIG(status);
-        setStatus("Child died because of signal " + itoa(sig));
+        setStatus("Child died because of signal " + std::to_string(sig));
         g_log << Logger::Error << "Our pdns instance (" << pid << ") exited after signal " << sig << endl;
 #ifdef WCOREDUMP
         if (WCOREDUMP(status))
index 7e8c961cbbadc3e9dbe30b7d4c0bfb3c9e584b28..bce52e8fbd789c0142b7cc021fa89c240f26849b 100644 (file)
@@ -215,7 +215,7 @@ void GSQLBackend::setNotified(uint32_t domain_id, uint32_t serial)
       reset();
   }
   catch(SSqlException &e) {
-    throw PDNSException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason());
+    throw PDNSException("GSQLBackend unable to refresh domain_id "+std::to_string(domain_id)+": "+e.txtReason());
   }
 }
 
@@ -227,7 +227,7 @@ void GSQLBackend::setLastCheck(uint32_t domain_id, time_t lastcheck)
     d_UpdateLastCheckOfZoneQuery_stmt->bind("last_check", lastcheck)->bind("domain_id", domain_id)->execute()->reset();
   }
   catch (SSqlException &e) {
-    throw PDNSException("GSQLBackend unable to update last_check for domain_id " + itoa(domain_id) + ": " + e.txtReason());
+    throw PDNSException("GSQLBackend unable to update last_check for domain_id " + std::to_string(domain_id) + ": " + e.txtReason());
   }
 }
 
@@ -730,7 +730,7 @@ bool GSQLBackend::updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName
           reset();
       }
       catch(SSqlException &e) {
-        throw PDNSException("GSQLBackend unable to update ordername and auth for " + qname.toLogString() + " for domain_id "+itoa(domain_id)+", domain name '" + qname.toLogString() + "': "+e.txtReason());
+        throw PDNSException("GSQLBackend unable to update ordername and auth for " + qname.toLogString() + " for domain_id "+std::to_string(domain_id)+", domain name '" + qname.toLogString() + "': "+e.txtReason());
       }
     } else {
       try {
@@ -746,7 +746,7 @@ bool GSQLBackend::updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName
           reset();
       }
       catch(SSqlException &e) {
-        throw PDNSException("GSQLBackend unable to update ordername and auth for " + qname.toLogString() + "|" + QType(qtype).toString() + " for domain_id "+itoa(domain_id)+": "+e.txtReason());
+        throw PDNSException("GSQLBackend unable to update ordername and auth for " + qname.toLogString() + "|" + QType(qtype).toString() + " for domain_id "+std::to_string(domain_id)+": "+e.txtReason());
       }
     }
   } else {
@@ -762,7 +762,7 @@ bool GSQLBackend::updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName
           reset();
       }
       catch(SSqlException &e) {
-        throw PDNSException("GSQLBackend unable to nullify ordername and update auth for " + qname.toLogString() + " for domain_id "+itoa(domain_id)+": "+e.txtReason());
+        throw PDNSException("GSQLBackend unable to nullify ordername and update auth for " + qname.toLogString() + " for domain_id "+std::to_string(domain_id)+": "+e.txtReason());
       }
     } else {
       try {
@@ -777,7 +777,7 @@ bool GSQLBackend::updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName
           reset();
       }
       catch(SSqlException &e) {
-        throw PDNSException("GSQLBackend unable to nullify ordername and update auth for " + qname.toLogString() + "|" + QType(qtype).toString() + " for domain_id "+itoa(domain_id)+": "+e.txtReason());
+        throw PDNSException("GSQLBackend unable to nullify ordername and update auth for " + qname.toLogString() + "|" + QType(qtype).toString() + " for domain_id "+std::to_string(domain_id)+": "+e.txtReason());
       }
     }
   }
@@ -796,7 +796,7 @@ bool GSQLBackend::updateEmptyNonTerminals(uint32_t domain_id, set<DNSName>& inse
         reset();
     }
     catch (SSqlException &e) {
-      throw PDNSException("GSQLBackend unable to delete empty non-terminal records from domain_id "+itoa(domain_id)+": "+e.txtReason());
+      throw PDNSException("GSQLBackend unable to delete empty non-terminal records from domain_id "+std::to_string(domain_id)+": "+e.txtReason());
     }
   }
   else
@@ -812,7 +812,7 @@ bool GSQLBackend::updateEmptyNonTerminals(uint32_t domain_id, set<DNSName>& inse
           reset();
       }
       catch (SSqlException &e) {
-        throw PDNSException("GSQLBackend unable to delete empty non-terminal rr '"+qname.toLogString()+"' from domain_id "+itoa(domain_id)+": "+e.txtReason());
+        throw PDNSException("GSQLBackend unable to delete empty non-terminal rr '"+qname.toLogString()+"' from domain_id "+std::to_string(domain_id)+": "+e.txtReason());
       }
     }
   }
@@ -830,7 +830,7 @@ bool GSQLBackend::updateEmptyNonTerminals(uint32_t domain_id, set<DNSName>& inse
         reset();
     }
     catch (SSqlException &e) {
-      throw PDNSException("GSQLBackend unable to insert empty non-terminal rr '"+qname.toLogString()+"' in domain_id "+itoa(domain_id)+": "+e.txtReason());
+      throw PDNSException("GSQLBackend unable to insert empty non-terminal rr '"+qname.toLogString()+"' in domain_id "+std::to_string(domain_id)+": "+e.txtReason());
     }
   }
 
@@ -866,7 +866,7 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qna
     d_afterOrderQuery_stmt->reset();
   }
   catch(SSqlException &e) {
-    throw PDNSException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+" and qname '"+ qname.toLogString() +"': "+e.txtReason());
+    throw PDNSException("GSQLBackend unable to find before/after (after) for domain_id "+std::to_string(id)+" and qname '"+ qname.toLogString() +"': "+e.txtReason());
   }
 
   if(after.empty()) {
@@ -884,7 +884,7 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qna
       d_firstOrderQuery_stmt->reset();
     }
     catch(SSqlException &e) {
-      throw PDNSException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+" and qname '"+ qname.toLogString() + "': "+e.txtReason());
+      throw PDNSException("GSQLBackend unable to find before/after (first) for domain_id "+std::to_string(id)+" and qname '"+ qname.toLogString() + "': "+e.txtReason());
     }
   }
 
@@ -911,7 +911,7 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qna
       d_beforeOrderQuery_stmt->reset();
     }
     catch(SSqlException &e) {
-      throw PDNSException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+" and qname '"+ qname.toLogString() + ": "+e.txtReason());
+      throw PDNSException("GSQLBackend unable to find before/after (before) for domain_id "+std::to_string(id)+" and qname '"+ qname.toLogString() + ": "+e.txtReason());
     }
 
     if(! unhashed.empty())
@@ -939,7 +939,7 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qna
       d_lastOrderQuery_stmt->reset();
     }
     catch(SSqlException &e) {
-      throw PDNSException("GSQLBackend unable to find before/after (last) for domain_id "+itoa(id)+" and qname '"+ qname.toLogString() + ": "+e.txtReason());
+      throw PDNSException("GSQLBackend unable to find before/after (last) for domain_id "+std::to_string(id)+" and qname '"+ qname.toLogString() + ": "+e.txtReason());
     }
   } else {
     before=qname;
@@ -1755,7 +1755,7 @@ bool GSQLBackend::replaceRRSet(uint32_t domain_id, const DNSName& qname, const Q
         d_DeleteRRSetQuery_stmt->
           bind("domain_id", domain_id)->
           bind("qname", qname)->
-          bind("qtype", "TYPE"+itoa(qt.getCode()))->
+          bind("qtype", "TYPE"+std::to_string(qt.getCode()))->
           execute()->
           reset();
       }
index 9f8243fd9eb4cf7299fb85901432108ff0f0f047..0b1056f2db6e6048cdd77b9fd6120745db452af7 100644 (file)
@@ -36,7 +36,7 @@ extern int linenumber;
 static void yyerror(const char *str)
 {
   extern char *current_filename;       
-  throw PDNSException("Error in bind configuration '"+string(current_filename)+"' on line "+itoa(linenumber)+": "+str);
+  throw PDNSException("Error in bind configuration '"+string(current_filename)+"' on line "+std::to_string(linenumber)+": "+str);
 }
 
 extern FILE *yyin;
index 64037a3ba22c34a7ecddb6d8a6e253a89b1263bf..b85d6969ab9e226f9bf71d00ede59cb90059894e 100644 (file)
@@ -336,8 +336,8 @@ string DLNotifyHandler(const vector<string>&parts, Utility::pid_t ppid)
     }
 
     if (total != notified)
-      return itoa(notified)+" out of "+itoa(total)+" zones added to queue - see log";
-    return "Added " + itoa(total) + " MASTER/SLAVE/PRODUCER/CONSUMER zones to queue";
+      return std::to_string(notified)+" out of "+std::to_string(total)+" zones added to queue - see log";
+    return "Added " + std::to_string(total) + " MASTER/SLAVE/PRODUCER/CONSUMER zones to queue";
   } else {
     DNSName domain;
     try {
index 3e98d332a05b65933e44b8c2fa40cd18bbd09c4a..7e5cb070636ce1d2d5d21ef1cb74d1c47b93effb 100644 (file)
@@ -507,20 +507,6 @@ std::string getCarbonHostName()
   return *hostname;
 }
 
-string itoa(int i)
-{
-  ostringstream o;
-  o<<i;
-  return o.str();
-}
-
-string uitoa(unsigned int i) // MSVC 6 doesn't grok overloading (un)signed
-{
-  ostringstream o;
-  o<<i;
-  return o.str();
-}
-
 string bitFlip(const string &str)
 {
   string::size_type pos=0, epos=str.size();
index 0f439369715f86d2253b8cfb001ab35fedb97f64..437cb63ea00fcf8f6c4cf813f60d8fd38a3290e9 100644 (file)
@@ -163,8 +163,6 @@ bool IpToU32(const string &str, uint32_t *ip);
 string U32ToIP(uint32_t);
 string stringerror(int);
 string stringerror();
-string itoa(int i);
-string uitoa(unsigned int i);
 string bitFlip(const string &str);
 
 void dropPrivs(int uid, int gid);
index 53d05c0edbe9ad30e45530864f264b468bc6ff4b..459a09d36279cb8627d0feb0d435d5e39341facf 100644 (file)
@@ -135,7 +135,7 @@ const string QType::toString() const
   if (name != numbers.cend()) {
     return name->second;
   }
-  return "TYPE" + itoa(code);
+  return "TYPE" + std::to_string(code);
 }
 
 uint16_t QType::chartocode(const char *p)
index 836c345f051d030eb49876624de279d8a9438e62..be649e079bfdf904a5b43b8a573ee9169458fa36 100644 (file)
@@ -204,7 +204,7 @@ namespace pdns {
         if(mdp.d_header.id != id)
           throw ResolverException("Remote nameserver replied with wrong id");
         if(mdp.d_header.qdcount != 1)
-          throw ResolverException("resolver: received answer with wrong number of questions ("+itoa(mdp.d_header.qdcount)+")");
+          throw ResolverException("resolver: received answer with wrong number of questions ("+std::to_string(mdp.d_header.qdcount)+")");
         if(mdp.d_qname != origQname)
           throw ResolverException(string("resolver: received an answer to another question (")+mdp.d_qname.toLogString()+"!="+ origQname.toLogString()+".)");
       }
index 80b8fa308169528fff3ffcb376b47c3cb2fce3be..ffce117ad8609daaed32f5d134cd820a69fc3b43 100644 (file)
@@ -659,7 +659,7 @@ int PacketHandler::processUpdate(DNSPacket& p) {
   if (! ::arg().mustDo("dnsupdate"))
     return RCode::Refused;
 
-  string msgPrefix="UPDATE (" + itoa(p.d.id) + ") from " + p.getRemoteString() + " for " + p.qdomain.toLogString() + ": ";
+  string msgPrefix="UPDATE (" + std::to_string(p.d.id) + ") from " + p.getRemoteString() + " for " + p.qdomain.toLogString() + ": ";
   g_log<<Logger::Info<<msgPrefix<<"Processing started."<<endl;
 
   // if there is policy, we delegate all checks to it
index b919b4e18927c3d7a38acf0ceb6b55129404d11c..8ccb469c5d15f0277a9151b3f1a8ed59ad90f754 100644 (file)
@@ -294,7 +294,7 @@ public:
   void setId(int id)
   {
     if(doLog())
-      d_prefix="["+itoa(id)+"] ";
+      d_prefix="["+std::to_string(id)+"] ";
   }
 
   void setLogMode(LogMode lm)