From c20313ec56a0d0c9ef15e5bc678a69df73d51bef Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 9 Jan 2023 10:22:19 +0100 Subject: [PATCH] Introduce a thread-safe version of stringerror() It turns out we already have the code, so call it. --- pdns/misc.cc | 10 ---------- pdns/misc.hh | 8 ++++++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pdns/misc.cc b/pdns/misc.cc index 7e5cb07063..efcf8779ec 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -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; diff --git a/pdns/misc.hh b/pdns/misc.hh index 437cb63ea0..231d626aca 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -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); -- 2.47.2