Skip to content

Commit

Permalink
Use more std::unreachable().
Browse files Browse the repository at this point in the history
  • Loading branch information
wilx committed Dec 8, 2024
1 parent f16c0a0 commit a6aad9d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/env.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ get_env_var (tstring & value, tstring const & name)
helpers::getLogLog().error(
LOG4CPLUS_TEXT ("_dupenv_s failed. Error: ")
+ helpers::convertIntegerToString (eno), true);
std::unreachable ();
}

return !! buf;
Expand Down
2 changes: 2 additions & 0 deletions src/hierarchy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ Hierarchy::getInstanceImpl(const tstring_view& name,
helpers::getLogLog().error(
LOG4CPLUS_TEXT("Hierarchy::getInstanceImpl()- Insert failed"),
true);
std::unreachable ();
}

if (auto pnm_it = provisionNodes.find(name); pnm_it != provisionNodes.end())
Expand Down Expand Up @@ -352,6 +353,7 @@ Hierarchy::updateParents(Logger const & logger)
helpers::getLogLog().error(
LOG4CPLUS_TEXT("Hierarchy::updateParents()- Insert failed"),
true);
std::unreachable ();
}
}
} // end if Logger found
Expand Down
30 changes: 22 additions & 8 deletions src/lockfile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ HANDLE
get_os_HANDLE (int fd)
{
HANDLE fh = reinterpret_cast<HANDLE>(_get_osfhandle (fd));
if (fh == INVALID_HANDLE_VALUE)
if (fh == INVALID_HANDLE_VALUE) {
getLogLog ().error (tstring (LOG4CPLUS_TEXT ("_get_osfhandle() failed: "))
+ convertIntegerToString (errno), true);
std::unreachable ();
}

return fh;
}
Expand Down Expand Up @@ -291,9 +293,11 @@ LockFile::lock () const
ret = LockFileEx(fh, LOCKFILE_EXCLUSIVE_LOCK, 0,
(std::numeric_limits<DWORD>::max) (),
(std::numeric_limits<DWORD>::max) (), &overlapped);
if (! ret)
if (! ret) {
getLogLog ().error (tstring (LOG4CPLUS_TEXT ("LockFileEx() failed: "))
+ convertIntegerToString (GetLastError ()), true);
std::unreachable ();
}

#elif defined (LOG4CPLUS_USE_O_EXLOCK)
open (OPEN_FLAGS | O_EXLOCK);
Expand All @@ -320,19 +324,23 @@ LockFile::lock () const
do
{
ret = lockf (data->fd, F_LOCK, 0);
if (ret == -1 && errno != EINTR)
if (ret == -1 && errno != EINTR) {
getLogLog ().error (tstring (LOG4CPLUS_TEXT("lockf() failed: "))
+ convertIntegerToString (errno), true);
std::unreachable ();
}
}
while (ret == -1);

#elif defined (LOG4CPLUS_USE_FLOCK)
do
{
ret = flock (data->fd, LOCK_EX);
if (ret == -1 && errno != EINTR)
if (ret == -1 && errno != EINTR) {
getLogLog ().error (tstring (LOG4CPLUS_TEXT("flock() failed: "))
+ convertIntegerToString (errno), true);
std::unreachable ();
}
}
while (ret == -1);

Expand All @@ -349,9 +357,11 @@ void LockFile::unlock () const

ret = UnlockFile(fh, 0, 0, (std::numeric_limits<DWORD>::max) (),
(std::numeric_limits<DWORD>::max) ());
if (! ret)
if (! ret) {
getLogLog ().error (tstring (LOG4CPLUS_TEXT ("UnlockFile() failed: "))
+ convertIntegerToString (GetLastError ()), true);
std::unreachable ();
}

#elif defined (LOG4CPLUS_USE_O_EXLOCK)
close ();
Expand All @@ -372,18 +382,22 @@ void LockFile::unlock () const

#elif defined (LOG4CPLUS_USE_LOCKF)
ret = lockf (data->fd, F_ULOCK, 0);
if (ret != 0)
if (ret != 0) {
getLogLog ().error (tstring (LOG4CPLUS_TEXT("lockf() failed: "))
+ convertIntegerToString (errno), true);
std::unreachable ();
}


#elif defined (LOG4CPLUS_USE_FLOCK)
ret = flock (data->fd, LOCK_UN);
if (ret != 0)
if (ret != 0) {
getLogLog ().error (tstring (LOG4CPLUS_TEXT("flock() failed: "))
+ convertIntegerToString (errno), true);
std::unreachable ();
}

#endif

}


Expand Down

0 comments on commit a6aad9d

Please sign in to comment.