clang-tidy: Enable bugprone-unchecked-optional-access
Enable bugprone-unchecked-optional-access to detect the case that it
accesses std::optional without checking empty.
See https://gerrit.openbmc.org/c/openbmc/docs/+/78034 for details.
This commit also fixes quite a few issues reported by clang-tidy:
* Add necessary includes in the hpp files;
* Move the template function `selAddSystemRecord()` into hpp;
* Fix the uncheck access of `expireAction`.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I4ad3cc07510a03965a2b4ae9c08fe452433ccdab
diff --git a/include/watchdog_event_monitor.hpp b/include/watchdog_event_monitor.hpp
index 990e25e..57ba24e 100644
--- a/include/watchdog_event_monitor.hpp
+++ b/include/watchdog_event_monitor.hpp
@@ -15,6 +15,8 @@
*/
#pragma once
+#include <boost/container/flat_map.hpp>
+#include <sdbusplus/bus/match.hpp>
#include <sel_logger.hpp>
#include <sensorutils.hpp>
@@ -84,6 +86,7 @@
if (!expireAction)
{
+ expireAction = "";
auto getExpireAction = watchdogStatus.find("ExpireAction");
if (getExpireAction != watchdogStatus.end())
{