]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Introduce a thread-safe version of stringerror() 12396/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 9 Jan 2023 09:22:19 +0000 (10:22 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 9 Jan 2023 11:17:28 +0000 (12:17 +0100)
It turns out we already have the code, so call it.

pdns/misc.cc
pdns/misc.hh

index 7e5cb070636ce1d2d5d21ef1cb74d1c47b93effb..efcf8779ecd7e0c312206bcb6e355d276a5aab6d 100644 (file)
@@ -517,16 +517,6 @@ string bitFlip(const string &str)
   return ret;
 }
 
-string stringerror(int err)
-{
-  return strerror(err);
-}
-
-string stringerror()
-{
-  return strerror(errno);
-}
-
 void cleanSlashes(string &str)
 {
   string::const_iterator i;
index 437cb63ea00fcf8f6c4cf813f60d8fd38a3290e9..231d626aca976dd787f4df806a56bbd2ffd2c522 100644 (file)
@@ -161,8 +161,12 @@ const string toLower(const string &upper);
 const string toLowerCanonic(const string &upper);
 bool IpToU32(const string &str, uint32_t *ip);
 string U32ToIP(uint32_t);
-string stringerror(int);
-string stringerror();
+
+inline string stringerror(int err = errno)
+{
+  return pdns::getMessageFromErrno(err);
+}
+
 string bitFlip(const string &str);
 
 void dropPrivs(int uid, int gid);