]> granicus.if.org Git - pdns/commitdiff
Remaining strerror(errno) -> stringerror() conversions
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 28 Jun 2019 14:58:20 +0000 (16:58 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 28 Jun 2019 14:58:20 +0000 (16:58 +0200)
17 files changed:
pdns/dnsdist-carbon.cc
pdns/dnsdist-tcp.cc
pdns/iputils.cc
pdns/ixfrdist.cc
pdns/ixfrutils.cc
pdns/lua-base4.cc
pdns/misc.cc
pdns/nameserver.cc
pdns/pdns_recursor.cc
pdns/pdnsutil.cc
pdns/rec-carbon.cc
pdns/rec-lua-conf.cc
pdns/receiver.cc
pdns/remote_logger.cc
pdns/resolver.cc
pdns/rpzloader.cc
pdns/sdig.cc

index e3fc46fa176dc517dc760d0bf6411df6da9f1373..1d5f468bce10fd3bf2422cca6249cf3b7713f515 100644 (file)
@@ -210,7 +210,7 @@ try
 
         int ret = waitForRWData(s.getHandle(), false, 1 , 0);
         if(ret <= 0 ) {
-          vinfolog("Unable to write data to carbon server on %s: %s", server.toStringWithPort(), (ret<0 ? strerror(errno) : "Timeout"));
+          vinfolog("Unable to write data to carbon server on %s: %s", server.toStringWithPort(), (ret<0 ? stringerror() : "Timeout"));
           continue;
         }
         s.setBlocking();
index 9021d4f7ad7bd29c08bb09ddf6a1dcc6d4eae1a4..60e47b261e0efcda211144931d62c600645b83a4 100644 (file)
@@ -269,7 +269,7 @@ void TCPClientCollection::addTCPClientThread()
   }
   else {
     if (pipe(pipefds) < 0) {
-      errlog("Error creating the TCP thread communication pipe: %s", strerror(errno));
+      errlog("Error creating the TCP thread communication pipe: %s", stringerror());
       return;
     }
 
index 2010a6e5f9ca5a2ecf951ed2d0899487e5ce9650..76dc1bf960597cfb655303c2486791ae1c8e7f98 100644 (file)
@@ -41,7 +41,7 @@ int SSocket(int family, int type, int flags)
 {
   int ret = socket(family, type, flags);
   if(ret < 0)
-    RuntimeError(boost::format("creating socket of type %d: %s") % family % strerror(errno));
+    RuntimeError(boost::format("creating socket of type %d: %s") % family % stringerror());
   return ret;
 }
 
@@ -116,7 +116,7 @@ int SAccept(int sockfd, ComboAddress& remote)
 
   int ret = accept(sockfd, (struct sockaddr*)&remote, &remlen);
   if(ret < 0)
-    RuntimeError(boost::format("accepting new connection on socket: %s") % strerror(errno));
+    RuntimeError(boost::format("accepting new connection on socket: %s") % stringerror());
   return ret;
 }
 
@@ -124,7 +124,7 @@ int SListen(int sockfd, int limit)
 {
   int ret = listen(sockfd, limit);
   if(ret < 0)
-    RuntimeError(boost::format("setting socket to listen: %s") % strerror(errno));
+    RuntimeError(boost::format("setting socket to listen: %s") % stringerror());
   return ret;
 }
 
@@ -132,7 +132,7 @@ int SSetsockopt(int sockfd, int level, int opname, int value)
 {
   int ret = setsockopt(sockfd, level, opname, &value, sizeof(value));
   if(ret < 0)
-    RuntimeError(boost::format("setsockopt for level %d and opname %d to %d failed: %s") % level % opname % value % strerror(errno));
+    RuntimeError(boost::format("setsockopt for level %d and opname %d to %d failed: %s") % level % opname % value % stringerror());
   return ret;
 }
 
index d23d554cbe245d1121880319a5cb95d7e709c59c..c572c335960d1f65deda1a6e56b1356ef58676cb 100644 (file)
@@ -308,7 +308,7 @@ void updateThread(const string& workdir, const uint16_t& keep, const uint16_t& a
       g_log<<Logger::Info<<e.what()<<", attempting to create"<<endl;
       // Attempt to create it, if _that_ fails, there is no hope
       if (mkdir(dir.c_str(), 0777) == -1 && errno != EEXIST) {
-        g_log<<Logger::Error<<"Could not create '"<<dir<<"': "<<strerror(errno)<<endl;
+        g_log<<Logger::Error<<"Could not create '"<<dir<<"': "<<stringerror()<<endl;
         _exit(EXIT_FAILURE);
       }
     }
index cd5f7155c6e4229e031862dec96a0a5bc4e449dd..b44529066cf4ed80076653ea68ffdf98a60ac2dc 100644 (file)
@@ -78,7 +78,7 @@ uint32_t getSerialsFromDir(const std::string& dir)
   uint32_t ret=0;
   DIR* dirhdl=opendir(dir.c_str());
   if(!dirhdl)
-    throw runtime_error("Could not open IXFR directory '" + dir + "': " + strerror(errno));
+    throw runtime_error("Could not open IXFR directory '" + dir + "': " + stringerror());
   struct dirent *entry;
 
   while((entry = readdir(dirhdl))) {
@@ -125,7 +125,7 @@ void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::s
   string fname=directory +"/"+std::to_string(serial);
   FILE* fp=fopen((fname+".partial").c_str(), "w");
   if(!fp)
-    throw runtime_error("Unable to open file '"+fname+".partial' for writing: "+string(strerror(errno)));
+    throw runtime_error("Unable to open file '"+fname+".partial' for writing: "+string(stringerror()));
 
   records_t soarecord;
   soarecord.insert(soa);
@@ -137,7 +137,7 @@ void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::s
 
   fclose(fp);
   if (rename( (fname+".partial").c_str(), fname.c_str()) != 0) {
-    throw std::runtime_error("Unable to move the zone file for " + zone.toLogString() + " from " + fname + ".partial to " + fname + ": " + string(strerror(errno)));
+    throw std::runtime_error("Unable to move the zone file for " + zone.toLogString() + " from " + fname + ".partial to " + fname + ": " + string(stringerror()));
   }
 }
 
index 39dbb391c3abdcad7f65e15dbd12bb6e32459f25..b0551007155de377ea02d8801999f644fc61f4c3 100644 (file)
@@ -18,7 +18,7 @@ BaseLua4::BaseLua4() {
 void BaseLua4::loadFile(const std::string &fname) {
   std::ifstream ifs(fname);
   if(!ifs) {
-    g_log<<Logger::Error<<"Unable to read configuration file from '"<<fname<<"': "<<strerror(errno)<<endl;
+    g_log<<Logger::Error<<"Unable to read configuration file from '"<<fname<<"': "<<stringerror()<<endl;
     return;
   }
   loadStream(ifs);
index 027856dfc1969217f2b8c3f005e48abfeb89b500..2967ac3f3b6f368fc20aaf0318524a3875e12ef7 100644 (file)
@@ -1091,7 +1091,7 @@ bool setReuseAddr(int sock)
 {
   int tmp = 1;
   if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&tmp, static_cast<unsigned>(sizeof tmp))<0)
-    throw PDNSException(string("Setsockopt failed: ")+strerror(errno));
+    throw PDNSException(string("Setsockopt failed: ")+stringerror());
   return true;
 }
 
@@ -1111,7 +1111,7 @@ bool setReceiveSocketErrors(int sock, int af)
     ret = setsockopt(sock, IPPROTO_IPV6, IPV6_RECVERR, &tmp, sizeof(tmp));
   }
   if (ret < 0) {
-    throw PDNSException(string("Setsockopt failed: ") + strerror(errno));
+    throw PDNSException(string("Setsockopt failed: ") + stringerror());
   }
 #endif
   return true;
index 55812391712774d76a0ad99c7365ad57e94bac66..e45fa5cb0ce9e55f3868cc3110aad4e6794419c0 100644 (file)
@@ -103,8 +103,8 @@ void UDPNameserver::bindIPv4()
     s=socket(AF_INET,SOCK_DGRAM,0);
 
     if(s<0) {
-      g_log<<Logger::Error<<"Unable to acquire UDP socket: "+string(strerror(errno)) << endl;
-      throw PDNSException("Unable to acquire a UDP socket: "+string(strerror(errno)));
+      g_log<<Logger::Error<<"Unable to acquire UDP socket: "+string(stringerror()) << endl;
+      throw PDNSException("Unable to acquire a UDP socket: "+string(stringerror()));
     }
   
     setCloseOnExec(s);
@@ -146,7 +146,7 @@ void UDPNameserver::bindIPv4()
         g_localaddresses.push_back(locala);
 
     if(::bind(s, (sockaddr*)&locala, locala.getSocklen()) < 0) {
-      string binderror = strerror(errno);
+      string binderror = stringerror();
       close(s);
       if( errno == EADDRNOTAVAIL && ! ::arg().mustDo("local-address-nonexist-fail") ) {
         g_log<<Logger::Error<<"IPv4 Address " << localname << " does not exist on this server - skipping UDP bind" << endl;
@@ -218,8 +218,8 @@ void UDPNameserver::bindIPv6()
         g_log<<Logger::Error<<"IPv6 Address Family is not supported - skipping UDPv6 bind" << endl;
         return;
       } else {
-        g_log<<Logger::Error<<"Unable to acquire a UDPv6 socket: "+string(strerror(errno)) << endl;
-        throw PDNSException("Unable to acquire a UDPv6 socket: "+string(strerror(errno)));
+        g_log<<Logger::Error<<"Unable to acquire a UDPv6 socket: "+string(stringerror()) << endl;
+        throw PDNSException("Unable to acquire a UDPv6 socket: "+string(stringerror()));
       }
     }
 
@@ -257,7 +257,7 @@ void UDPNameserver::bindIPv6()
         g_log<<Logger::Error<<"IPv6 Address " << localname << " does not exist on this server - skipping UDP bind" << endl;
         continue;
       } else {
-        g_log<<Logger::Error<<"Unable to bind to UDPv6 socket "<< localname <<": "<<strerror(errno)<<endl;
+        g_log<<Logger::Error<<"Unable to bind to UDPv6 socket "<< localname <<": "<<stringerror()<<endl;
         throw PDNSException("Unable to bind to UDPv6 socket");
       }
     }
@@ -308,7 +308,7 @@ void UDPNameserver::send(DNSPacket *p)
     g_log<<Logger::Error<<"Weird, trying to send a message that needs truncation, "<< buffer.length()<<" > "<<p->getMaxReplyLen()<<". Question was for "<<p->qdomain<<"|"<<p->qtype.getName()<<endl;
   }
   if(sendmsg(p->getSocket(), &msgh, 0) < 0)
-    g_log<<Logger::Error<<"Error sending reply with sendmsg (socket="<<p->getSocket()<<", dest="<<p->d_remote.toStringWithPort()<<"): "<<strerror(errno)<<endl;
+    g_log<<Logger::Error<<"Error sending reply with sendmsg (socket="<<p->getSocket()<<", dest="<<p->d_remote.toStringWithPort()<<"): "<<stringerror()<<endl;
 }
 
 DNSPacket *UDPNameserver::receive(DNSPacket *prefilled, std::string& buffer)
@@ -347,7 +347,7 @@ DNSPacket *UDPNameserver::receive(DNSPacket *prefilled, std::string& buffer)
       sock=pfd.fd;        
       if((len=recvmsg(sock, &msgh, 0)) < 0 ) {
         if(errno != EAGAIN)
-          g_log<<Logger::Error<<"recvfrom gave error, ignoring: "<<strerror(errno)<<endl;
+          g_log<<Logger::Error<<"recvfrom gave error, ignoring: "<<stringerror()<<endl;
         return 0;
       }
       break;
index 20589465d49c6fad93a93f3d49c3267bdc846ab3..71f054a1300eed86f560e2a279263a016b0ffb7e 100644 (file)
@@ -446,7 +446,7 @@ static void handleGenUDPQueryResponse(int fd, FDMultiplexer::funcparam_t& var)
   else {
     string empty;
     MT->sendEvent(pident, &empty);
-    //    cerr<<"Had some kind of error: "<<ret<<", "<<strerror(errno)<<endl;
+    //    cerr<<"Had some kind of error: "<<ret<<", "<<stringerror()<<endl;
   }
 }
 string GenUDPQueryResponse(const ComboAddress& dest, const string& query)
index be61c6cdf3d07b76545c65f5867b9d9e03a2fe61..5c9e71d1c7452df0ceb3fa6240f2fcb479fc9dae 100644 (file)
@@ -135,7 +135,7 @@ void loadMainConfig(const std::string& configdir)
 
   // Keep this line below all ::arg().set() statements
   if (! ::arg().laxFile(configname.c_str()))
-    cerr<<"Warning: unable to read configuration file '"<<configname<<"': "<<strerror(errno)<<endl;
+    cerr<<"Warning: unable to read configuration file '"<<configname<<"': "<<stringerror()<<endl;
 
 #ifdef HAVE_LIBSODIUM
   if (sodium_init() == -1) {
index 5f2b92fa08e42db31a8d5f65c2488bb9bf65556c..218ee83716972150ee34aaac46406c1dcf0fcdfd 100644 (file)
@@ -70,7 +70,7 @@ try
 
     int ret=asendtcp(msg, &s);     // this will actually do the right thing waiting on the connect
     if(ret < 0)
-      g_log<<Logger::Warning<<"Error writing carbon data to "<<remote.toStringWithPort()<<": "<<strerror(errno)<<endl;
+      g_log<<Logger::Warning<<"Error writing carbon data to "<<remote.toStringWithPort()<<": "<<stringerror()<<endl;
     if(ret==0)
       g_log<<Logger::Warning<<"Timeout connecting/writing carbon data to "<<remote.toStringWithPort()<<endl;
   }
index 1b7dfe6fdbb749aa00fb660eef041d658b8b3737..8b46c820b9bf4965374157f02d123bcfb361aec7 100644 (file)
@@ -191,7 +191,7 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de
     return;
   ifstream ifs(fname);
   if(!ifs)
-    throw PDNSException("Cannot open file '"+fname+"': "+strerror(errno));
+    throw PDNSException("Cannot open file '"+fname+"': "+stringerror());
 
   auto luaconfsLocal = g_luaconfs.getLocal();
   lci.generation = luaconfsLocal->generation + 1;
index e6686787b38ef9c19a265df5d66759525cf3e38c..d7b47f27ef2f2478a12bdcb3933ff9e29f087e50 100644 (file)
@@ -149,7 +149,7 @@ static void writePid(void)
   if(of)
     of<<getpid()<<endl;
   else
-    g_log<<Logger::Error<<"Writing pid for "<<getpid()<<" to "<<fname<<" failed: "<<strerror(errno)<<endl;
+    g_log<<Logger::Error<<"Writing pid for "<<getpid()<<" to "<<fname<<" failed: "<<stringerror()<<endl;
 }
 
 int g_fd1[2], g_fd2[2];
@@ -223,7 +223,7 @@ static int guardian(int argc, char **argv)
     setStatus("Launching child");
     
     if(pipe(g_fd1)<0 || pipe(g_fd2)<0) {
-      g_log<<Logger::Critical<<"Unable to open pipe for coprocess: "<<strerror(errno)<<endl;
+      g_log<<Logger::Critical<<"Unable to open pipe for coprocess: "<<stringerror()<<endl;
       exit(1);
     }
 
@@ -268,7 +268,7 @@ static int guardian(int argc, char **argv)
         close(g_fd2[1]);
       }
       if(execvp(argv[0], newargv)<0) {
-        g_log<<Logger::Error<<"Unable to execvp '"<<argv[0]<<"': "<<strerror(errno)<<endl;
+        g_log<<Logger::Error<<"Unable to execvp '"<<argv[0]<<"': "<<stringerror()<<endl;
         char **p=newargv;
         while(*p)
           g_log<<Logger::Error<<*p++<<endl;
@@ -299,7 +299,7 @@ static int guardian(int argc, char **argv)
         int ret=waitpid(pid,&status,WNOHANG);
 
         if(ret<0) {
-          g_log<<Logger::Error<<"In guardian loop, waitpid returned error: "<<strerror(errno)<<endl;
+          g_log<<Logger::Error<<"In guardian loop, waitpid returned error: "<<stringerror()<<endl;
           g_log<<Logger::Error<<"Dying"<<endl;
           exit(1);
         }
@@ -348,7 +348,7 @@ static int guardian(int argc, char **argv)
       g_log<<Logger::Error<<"No clue what happened! Respawning"<<endl;
     }
     else {
-      g_log<<Logger::Error<<"Unable to fork: "<<strerror(errno)<<endl;
+      g_log<<Logger::Error<<"Unable to fork: "<<stringerror()<<endl;
       exit(1);
     }
   }
@@ -575,7 +575,7 @@ int main(int argc, char **argv)
       if(gethostname(tmp, sizeof(tmp)-1) == 0) {
         ::arg().set("server-id")=tmp;
       } else {
-        g_log<<Logger::Warning<<"Unable to get the hostname, NSID and id.server values will be empty: "<<strerror(errno)<<endl;
+        g_log<<Logger::Warning<<"Unable to get the hostname, NSID and id.server values will be empty: "<<stringerror()<<endl;
       }
     }
 
index 8863fa1954faa27db7c57a418387a232086dd682..627f73a1e5fe9db4a5c1139a35f9032ce9883440 100644 (file)
@@ -48,7 +48,7 @@ void CircularWriteBuffer::flush()
 
   int res = writev(d_fd, iov, pos);
   if(res < 0) {
-    throw std::runtime_error("Couldn't flush a thing: "+string(strerror(errno)));
+    throw std::runtime_error("Couldn't flush a thing: "+string(stringerror()));
   }
   if(!res) {
     throw std::runtime_error("EOF");
index fb8c830dbd10952ab2067dec7ee9cb9d4db1d931..19e499dbd68a2c4d814f420e3c17be08eb009a9d 100644 (file)
@@ -558,7 +558,7 @@ void AXFRRetriever::connect(uint16_t timeout)
     throw ResolverException("Timeout connecting to server");
   }
   else if(err < 0) {
-    throw ResolverException("Error connecting: "+string(strerror(errno)));
+    throw ResolverException("Error connecting: "+string(stringerror()));
   }
   else {
     Utility::socklen_t len=sizeof(err);
index df08141db65b747654da4075a88dd4206232bfff..c4a908275d084067787f05588ed9fe673264c08f 100644 (file)
@@ -322,22 +322,22 @@ static bool dumpZoneToDisk(const DNSName& zoneName, const std::shared_ptr<DNSFil
   }
 
   if (fflush(fp.get()) != 0) {
-    g_log<<Logger::Warning<<"Error while flushing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<strerror(errno)<<endl;
+    g_log<<Logger::Warning<<"Error while flushing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<stringerror()<<endl;
     return false;
   }
 
   if (fsync(fileno(fp.get())) != 0) {
-    g_log<<Logger::Warning<<"Error while syncing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<strerror(errno)<<endl;
+    g_log<<Logger::Warning<<"Error while syncing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<stringerror()<<endl;
     return false;
   }
 
   if (fclose(fp.release()) != 0) {
-    g_log<<Logger::Warning<<"Error while writing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<strerror(errno)<<endl;
+    g_log<<Logger::Warning<<"Error while writing the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<stringerror()<<endl;
     return false;
   }
 
   if (rename(temp.c_str(), dumpZoneFileName.c_str()) != 0) {
-    g_log<<Logger::Warning<<"Error while moving the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<strerror(errno)<<endl;
+    g_log<<Logger::Warning<<"Error while moving the content of the RPZ zone "<<zoneName.toLogString()<<" to the dump file: "<<stringerror()<<endl;
     return false;
   }
 
index 28a24f678ae17e963a356ed7449d9d0264e3684c..7aa4732b38536352e56397e0fae4cbffefc3be06 100644 (file)
@@ -208,7 +208,7 @@ try
     sock.sendTo(question, dest);
     int result=waitForData(sock.getHandle(), 10);
     if(result < 0) 
-      throw std::runtime_error("Error waiting for data: "+string(strerror(errno)));
+      throw std::runtime_error("Error waiting for data: "+string(stringerror()));
     if(!result)
       throw std::runtime_error("Timeout waiting for data");
     sock.recvFrom(reply, dest);