summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-01-06 23:45:54 +0300
committerEd Tanous <ed@tanous.net>2022-01-12 21:32:14 +0300
commit24b2fe810e784f04728379f49af54a3ab2252c9b (patch)
tree9ea535360f1e80603fcb599013f42263846e700d /src
parentf94c4ecf9cf61b91b552731e4e03cd84c1070972 (diff)
downloadbmcweb-24b2fe810e784f04728379f49af54a3ab2252c9b.tar.xz
enable bugprone exception escape check
clang-13 includes new checks, and finds some issues. The first is that the boost::vector constructor can possibly throw, so replace the underlying flat_map container with std::vector instead. The others are places where we could possibly throw in destructors, which would be bad. Ideally we wouldn't use the destructor pattern, but that would be non-trivial to clean up at this point, so just catch the exception, and log it. At the same time, catch exceptions thrown to main and log them. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I77b86eaa2fc79e43d1ca044c78ca3b0ce0a7c38c
Diffstat (limited to 'src')
-rw-r--r--src/webserver_main.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index bf98aae73b..b613008360 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -61,7 +61,7 @@ inline void setupSocket(crow::App& app)
}
}
-int main(int /*argc*/, char** /*argv*/)
+int run()
{
crow::Logger::setLogLevel(crow::LogLevel::Debug);
@@ -146,3 +146,16 @@ int main(int /*argc*/, char** /*argv*/)
crow::connections::systemBus.reset();
return 0;
}
+
+int main(int /*argc*/, char** /*argv*/)
+{
+ try
+ {
+ return run();
+ }
+ catch (...)
+ {
+ return -1;
+ BMCWEB_LOG_CRITICAL << "Threw exception to main";
+ }
+}