Logging cleanups
This patch removes some test-specific logging code in favor of death tests, and
makes the OSP_NOTREACHED macro actually be annotated as [[noreturn]], so you
don't have to put a bogus return statement after it.
Change-Id: I6a6a271182061cbd98593ac0ae79347e48da5bc7
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2555597
Commit-Queue: Jordan Bayles <jophba@chromium.org>
Reviewed-by: Brandon Tolsch <btolsch@chromium.org>
diff --git a/platform/impl/logging_posix.cc b/platform/impl/logging_posix.cc
index 6e9564c..e666998 100644
--- a/platform/impl/logging_posix.cc
+++ b/platform/impl/logging_posix.cc
@@ -22,7 +22,6 @@
int g_log_fd = STDERR_FILENO;
LogLevel g_log_level = LogLevel::kWarning;
std::vector<std::string>* g_log_messages_for_test = nullptr;
-bool* g_break_was_called_for_test = nullptr;
std::ostream& operator<<(std::ostream& os, const LogLevel& level) {
const char* level_string = "";
@@ -110,11 +109,10 @@
}
}
-void Break() {
- if (g_break_was_called_for_test) {
- *g_break_was_called_for_test = true;
- return;
- }
+[[noreturn]] void Break() {
+// Generally this will just resolve to an abort anyways, but gives the
+// compiler a chance to peform a more appropriate, target specific trap
+// as appropriate.
#if defined(_DEBUG)
__builtin_trap();
#else
@@ -126,8 +124,4 @@
g_log_messages_for_test = messages;
}
-void DisableBreakForTest(bool* break_was_called) {
- g_break_was_called_for_test = break_was_called;
-}
-
} // namespace openscreen