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
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index a48fd77..3a955cb 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -1480,7 +1480,7 @@
"xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 0,
std::array<const char*, 1>{thermalModeIface});
}
- ~SetPIDValues()
+ void pidSetDone()
{
if (asyncResp->res.result() != boost::beast::http::status::ok)
{
@@ -1683,6 +1683,19 @@
}
}
}
+
+ ~SetPIDValues()
+ {
+ try
+ {
+ pidSetDone();
+ }
+ catch (...)
+ {
+ BMCWEB_LOG_CRITICAL << "pidSetDone threw exception";
+ }
+ }
+
std::shared_ptr<bmcweb::AsyncResp> asyncResp;
std::vector<std::pair<std::string, std::optional<nlohmann::json>>>
configuration;