]> granicus.if.org Git - pdns/commitdiff
And a sweep of .hh files for stringerror(errno) -> stringerror()
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 1 Jul 2019 08:07:41 +0000 (10:07 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 1 Jul 2019 08:07:41 +0000 (10:07 +0200)
Plus zap some redundant string conversions.

pdns/dnsdist.hh
pdns/ixfrutils.cc
pdns/nameserver.cc
pdns/remote_logger.cc
pdns/resolver.cc
pdns/sdig.cc
pdns/sstuff.hh
pdns/tcpiohandler.hh

index a96a87b439d17ff920bc7e65eb0ae8d642b9eb99..d822acba780e342ecb2b2cd132ce5b2ec1f2dfb3 100644 (file)
@@ -694,21 +694,22 @@ public:
 
     if (d_useSinglePipe) {
       if (pipe(d_singlePipe) < 0) {
-        throw std::runtime_error("Error creating the TCP single communication pipe: " + string(strerror(errno)));
+        int err = errno;
+        throw std::runtime_error("Error creating the TCP single communication pipe: " + stringerror(err));
       }
 
       if (!setNonBlocking(d_singlePipe[0])) {
         int err = errno;
         close(d_singlePipe[0]);
         close(d_singlePipe[1]);
-        throw std::runtime_error("Error setting the TCP single communication pipe non-blocking: " + string(strerror(err)));
+        throw std::runtime_error("Error setting the TCP single communication pipe non-blocking: " + stringerror(err));
       }
 
       if (!setNonBlocking(d_singlePipe[1])) {
         int err = errno;
         close(d_singlePipe[0]);
         close(d_singlePipe[1]);
-        throw std::runtime_error("Error setting the TCP single communication pipe non-blocking: " + string(strerror(err)));
+        throw std::runtime_error("Error setting the TCP single communication pipe non-blocking: " + stringerror(err));
       }
     }
   }
index b44529066cf4ed80076653ea68ffdf98a60ac2dc..b9a342abb7c5c65c107c3a9d39474fe7d5f2d33f 100644 (file)
@@ -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(stringerror()));
+    throw runtime_error("Unable to open file '"+fname+".partial' for writing: "+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(stringerror()));
+    throw std::runtime_error("Unable to move the zone file for " + zone.toLogString() + " from " + fname + ".partial to " + fname + ": " + stringerror());
   }
 }
 
index e45fa5cb0ce9e55f3868cc3110aad4e6794419c0..4e56ac6a2a07ea1bf34819f3de875eb0bc621163 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(stringerror()) << endl;
-      throw PDNSException("Unable to acquire a UDP socket: "+string(stringerror()));
+      g_log<<Logger::Error<<"Unable to acquire UDP socket: "+stringerror() << endl;
+      throw PDNSException("Unable to acquire a UDP socket: "+stringerror());
     }
   
     setCloseOnExec(s);
@@ -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(stringerror()) << endl;
-        throw PDNSException("Unable to acquire a UDPv6 socket: "+string(stringerror()));
+        g_log<<Logger::Error<<"Unable to acquire a UDPv6 socket: "+stringerror() << endl;
+        throw PDNSException("Unable to acquire a UDPv6 socket: "+stringerror());
       }
     }
 
index 627f73a1e5fe9db4a5c1139a35f9032ce9883440..69934b98a9517850e31c17d31bcbd686cbab3083 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(stringerror()));
+    throw std::runtime_error("Couldn't flush a thing: "+stringerror());
   }
   if(!res) {
     throw std::runtime_error("EOF");
index 19e499dbd68a2c4d814f420e3c17be08eb009a9d..34113c060f0bc25badb24991ff6f602020ecfdc7 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(stringerror()));
+    throw ResolverException("Error connecting: "+stringerror());
   }
   else {
     Utility::socklen_t len=sizeof(err);
index 7aa4732b38536352e56397e0fae4cbffefc3be06..81e69116387715cb577b2d1a18acfca57a742995 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(stringerror()));
+      throw std::runtime_error("Error waiting for data: "+stringerror());
     if(!result)
       throw std::runtime_error("Timeout waiting for data");
     sock.recvFrom(reply, dest);
index 922315a5e21bc3aeeb2c1c4bd1c321b0d29030b1..cb75335509cd30d240cb19e6b77affc3cbb428cc 100644 (file)
@@ -56,7 +56,7 @@ public:
   Socket(int af, int st, ProtocolType pt=0)
   {
     if((d_socket=socket(af, st, pt))<0)
-      throw NetworkError(strerror(errno));
+      throw NetworkError(stringerror());
     setCloseOnExec(d_socket);
   }
 
@@ -87,7 +87,7 @@ public:
       if(errno==EAGAIN)
         return nullptr;
 
-      throw NetworkError("Accepting a connection: "+string(strerror(errno)));
+      throw NetworkError("Accepting a connection: "+stringerror());
     }
 
     return std::unique_ptr<Socket>(new Socket(s));
@@ -135,10 +135,10 @@ public:
   {
     int tmp=1;
     if(reuseaddr && setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char*>(&tmp), sizeof tmp)<0)
-      throw NetworkError(string("Setsockopt failed: ")+strerror(errno));
+      throw NetworkError("Setsockopt failed: "+stringerror());
 
     if(::bind(d_socket, reinterpret_cast<const struct sockaddr *>(&local), local.getSocklen())<0)
-      throw NetworkError("While binding: "+string(strerror(errno)));
+      throw NetworkError("While binding: "+stringerror());
   }
 
   //! Connect the socket to a specified endpoint
@@ -158,7 +158,7 @@ public:
     ssize_t bytes;
     d_buffer.resize(s_buflen);
     if((bytes=recvfrom(d_socket, &d_buffer[0], s_buflen, 0, reinterpret_cast<sockaddr *>(&ep) , &remlen)) <0)
-      throw NetworkError("After recvfrom: "+string(strerror(errno)));
+      throw NetworkError("After recvfrom: "+stringerror());
     
     dgram.assign(d_buffer, 0, static_cast<size_t>(bytes));
   }
@@ -171,7 +171,7 @@ public:
     d_buffer.resize(s_buflen);
     if((bytes=recvfrom(d_socket, &d_buffer[0], s_buflen, 0, reinterpret_cast<sockaddr *>(&remote), &remlen))<0) {
       if(errno!=EAGAIN) {
-        throw NetworkError("After async recvfrom: "+string(strerror(errno)));
+        throw NetworkError("After async recvfrom: "+stringerror());
       }
       else {
         return false;
@@ -186,14 +186,14 @@ public:
   void sendTo(const char* msg, size_t len, const ComboAddress &ep)
   {
     if(sendto(d_socket, msg, len, 0, reinterpret_cast<const sockaddr *>(&ep), ep.getSocklen())<0)
-      throw NetworkError("After sendto: "+string(strerror(errno)));
+      throw NetworkError("After sendto: "+stringerror());
   }
 
   //! For connected datagram sockets, send a datagram
   void send(const std::string& msg)
   {
     if(::send(d_socket, msg.c_str(), msg.size(), 0)<0)
-      throw NetworkError("After send: "+string(strerror(errno)));
+      throw NetworkError("After send: "+stringerror());
   }
 
   
@@ -219,7 +219,7 @@ public:
     do {
       res=::send(d_socket, ptr, toWrite, 0);
       if(res<0) 
-        throw NetworkError("Writing to a socket: "+string(strerror(errno)));
+        throw NetworkError("Writing to a socket: "+stringerror());
       if(!res)
         throw NetworkError("EOF on socket");
       toWrite -= static_cast<size_t>(res);
@@ -246,7 +246,7 @@ public:
     if(errno==EAGAIN)
       return 0;
     
-    throw NetworkError("Writing to a socket: "+string(strerror(errno)));
+    throw NetworkError("Writing to a socket: "+stringerror());
   }
 
   //! Writes toWrite bytes from ptr to the socket
@@ -256,7 +256,7 @@ public:
     ssize_t res;
     res=::send(d_socket,ptr,toWrite,0);
     if(res<0) {
-      throw NetworkError("Writing to a socket: "+string(strerror(errno)));
+      throw NetworkError("Writing to a socket: "+stringerror());
     }
     return res;
   }
@@ -317,7 +317,7 @@ public:
     d_buffer.resize(s_buflen);
     ssize_t res=::recv(d_socket, &d_buffer[0], s_buflen, 0);
     if(res<0) 
-      throw NetworkError("Reading from a socket: "+string(strerror(errno)));
+      throw NetworkError("Reading from a socket: "+stringerror());
     data.assign(d_buffer, 0, static_cast<size_t>(res));
   }
 
@@ -326,7 +326,7 @@ public:
   {
     ssize_t res=::recv(d_socket, buffer, bytes, 0);
     if(res<0) 
-      throw NetworkError("Reading from a socket: "+string(strerror(errno)));
+      throw NetworkError("Reading from a socket: "+stringerror());
     return static_cast<size_t>(res);
   }
 
@@ -337,7 +337,7 @@ public:
     if(err == 0)
       throw NetworkError("timeout reading");
     if(err < 0)
-      throw NetworkError("nonblocking read failed: "+string(strerror(errno)));
+      throw NetworkError("nonblocking read failed: "+stringerror());
 
     return read(buffer, n);
   }
@@ -346,7 +346,7 @@ public:
   void listen(unsigned int length=10)
   {
     if(::listen(d_socket,length)<0)
-      throw NetworkError("Setting socket to listen: "+string(strerror(errno)));
+      throw NetworkError("Setting socket to listen: "+stringerror());
   }
 
   //! Returns the internal file descriptor of the socket
index dd82281a7a81331f63b3abe98ab7eda7d6d49e62..e125e16f1bce03d12cbd1b3d60bb6d898d963fff 100644 (file)
@@ -219,7 +219,7 @@ public:
           return IOState::NeedRead;
         }
         else {
-          throw std::runtime_error(std::string("Error while reading message: ") + strerror(errno));
+          throw std::runtime_error("Error while reading message: " + stringerror());
         }
       }
 
@@ -254,7 +254,7 @@ public:
           return IOState::NeedWrite;
         }
         else {
-          throw std::runtime_error(std::string("Error while writing message: ") + strerror(errno));
+          throw std::runtime_error("Error while writing message: " + stringerror());
         }
       }