Skip to content

Commit

Permalink
wsd: avoid underscored errno
Browse files Browse the repository at this point in the history
Change-Id: I034044386d6c0914bb2399c8e33041f47deacbb2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
  • Loading branch information
Ashod authored and mmeeks committed Nov 2, 2024
1 parent a1d088e commit 23d1b15
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions common/FileUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<std::string> getDirEntries(const std::string dirPath);
Expand Down
8 changes: 4 additions & 4 deletions net/NetUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions net/NetUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class HostEntry
std::string _canonicalName;
std::vector<std::string> _ipAddresses;
std::shared_ptr<addrinfo> _ainfo;
int _errno;
int _saved_errno;
int _eaino;

void setEAI(int eaino);
Expand All @@ -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; }
Expand Down

0 comments on commit 23d1b15

Please sign in to comment.