diff --git a/common/FileUtil.hpp b/common/FileUtil.hpp index 144768061d67..2d3b34bf72c0 100644 --- a/common/FileUtil.hpp +++ b/common/FileUtil.hpp @@ -192,13 +192,13 @@ namespace FileUtil : _path(file) , _sb{} , _res(link ? lstat(file.c_str(), &_sb) : stat(file.c_str(), &_sb)) - , _errno(errno) + , _stat_errno(errno) { } bool good() const { return _res == 0; } bool bad() const { return !good(); } - bool erno() const { return _errno; } + bool erno() const { return _stat_errno; } const struct ::stat& sb() const { return _sb; } const std::string path() const { return _path; } @@ -251,7 +251,7 @@ namespace FileUtil } /// Returns true iff the path exists, regardless of access permission. - bool exists() const { return good() || (_errno != ENOENT && _errno != ENOTDIR); } + bool exists() const { return good() || (_stat_errno != ENOENT && _stat_errno != ENOTDIR); } /// Returns true if both files exist and have /// the same size and same contents. @@ -291,7 +291,7 @@ namespace FileUtil const std::string _path; struct ::stat _sb; const int _res; - const int _errno; + const int _stat_errno; }; std::vector getDirEntries(const std::string dirPath); diff --git a/net/NetUtil.cpp b/net/NetUtil.cpp index 71c30317d03f..6f30e1728fec 100644 --- a/net/NetUtil.cpp +++ b/net/NetUtil.cpp @@ -64,7 +64,7 @@ std::string HostEntry::makeIPAddress(const sockaddr* ai_addr) const char* result = inet_ntop(ai_addr->sa_family, inAddr, addrstr, sizeof(addrstr)); if (!result) { - _errno = errno; + _saved_errno = errno; LOG_WRN("inet_ntop failure: " << errorMessage()); return std::string(); } @@ -76,7 +76,7 @@ void HostEntry::setEAI(int eaino) _eaino = eaino; // EAI_SYSTEM: Other system error; errno is set to indicate the error. if (_eaino == EAI_SYSTEM) - _errno = errno; + _saved_errno = errno; } std::string HostEntry::errorMessage() const @@ -85,13 +85,13 @@ std::string HostEntry::errorMessage() const if (_eaino && _eaino != EAI_SYSTEM) errmsg = gai_strerror(_eaino); else - errmsg = strerror(_errno); + errmsg = strerror(_saved_errno); return std::string("[" + _requestName + "]: " + errmsg); } HostEntry::HostEntry(const std::string& desc, const char* port) : _requestName(desc) - , _errno(0) + , _saved_errno(0) , _eaino(0) { addrinfo hints; diff --git a/net/NetUtil.hpp b/net/NetUtil.hpp index 412a86671054..fad832750ace 100644 --- a/net/NetUtil.hpp +++ b/net/NetUtil.hpp @@ -46,7 +46,7 @@ class HostEntry std::string _canonicalName; std::vector _ipAddresses; std::shared_ptr _ainfo; - int _errno; + int _saved_errno; int _eaino; void setEAI(int eaino); @@ -57,7 +57,7 @@ class HostEntry HostEntry(const std::string& desc, const char* port); ~HostEntry(); - bool good() const { return _errno == 0 && _eaino == 0; } + bool good() const { return _saved_errno == 0 && _eaino == 0; } std::string errorMessage() const; const std::string& getCanonicalName() const { return _canonicalName; }