From 58fb91315e33a265c6f70a90684d3017e428fec4 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Wed, 9 Apr 2025 08:39:47 -0700 Subject: [PATCH] Revert addition of std::unreachable After further testing with the fuzzer corpus, std::unreachable isn't necessary here. It's fine to just let the default case break to fix the Coverity warning. --- src/analyzer/protocol/pop3/POP3.cc | 4 ++-- src/util.h | 15 --------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/analyzer/protocol/pop3/POP3.cc b/src/analyzer/protocol/pop3/POP3.cc index 9379fe738a..d9d2466ae7 100644 --- a/src/analyzer/protocol/pop3/POP3.cc +++ b/src/analyzer/protocol/pop3/POP3.cc @@ -673,7 +673,7 @@ void POP3_Analyzer::ProcessReply(int length, const char* line) { masterState = detail::POP3_UPDATE; break; - default: util::unreachable(); + default: break; } POP3Event(pop3_reply, false, cmd, message); @@ -728,7 +728,7 @@ void POP3_Analyzer::ProcessReply(int length, const char* line) { masterState == detail::POP3_START ) masterState = detail::POP3_FINISHED; break; - default: util::unreachable(); + default: break; } POP3Event(pop3_reply, false, cmd, message); diff --git a/src/util.h b/src/util.h index bfe1fdae5e..d950c9df17 100644 --- a/src/util.h +++ b/src/util.h @@ -661,20 +661,5 @@ inline std::vector split(const wchar_t* s, const wchar_t* del return split(std::wstring_view(s), std::wstring_view(delim)); } -/** - * Implementation of std::unreachable. Once C++23 is supported this can be replaced with - * an alias. This implementation is taken from cppreference. - */ -[[noreturn]] inline void unreachable() { - // Uses compiler specific extensions if possible. Even if no extension is used, - // undefined behavior is still raised by an empty function body and the noreturn - // attribute. -#if defined(_MSC_VER) && ! defined(__clang__) // MSVC - __assume(false); -#else // GCC, Clang - __builtin_unreachable(); -#endif -} - } // namespace util } // namespace zeek