clang-tidy: Enable bugprone-unchecked-optional
Modified code to address issues flagged by
bugprone-unchecked-optional-access check.
Tested: Build and unit tests passed successfully.
Change-Id: Icd445afaf827f7c346e44dfe3ce9ba98374e176a
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>
diff --git a/.clang-tidy b/.clang-tidy
index 502f430..0dc7755 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -66,6 +66,7 @@
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
+bugprone-unchecked-optional-access,
bugprone-undefined-memory-manipulation,
bugprone-undelegated-constructor,
bugprone-unhandled-exception-at-new,
diff --git a/dump_manager_bmc.cpp b/dump_manager_bmc.cpp
index a3402c1..3741f83 100644
--- a/dump_manager_bmc.cpp
+++ b/dump_manager_bmc.cpp
@@ -70,7 +70,8 @@
}
lg2::info("Initiating new BMC dump with type: {TYPE} path: {PATH}", "TYPE",
- dumpTypeToString(dumpType).value(), "PATH", path);
+ dumpTypeToString(dumpType).value_or("unknown").c_str(), "PATH",
+ path);
auto id = captureDump(dumpType, path);
@@ -118,7 +119,7 @@
auto id = std::to_string(lastEntryId + 1);
dumpPath /= id;
- auto strType = dumpTypeToString(type).value();
+ auto strType = dumpTypeToString(type).value_or("unknown");
execl("/usr/bin/dreport", "dreport", "-d", dumpPath.c_str(), "-i",
id.c_str(), "-s", std::to_string(size).c_str(), "-q", "-v", "-p",
path.empty() ? "" : path.c_str(), "-t", strType.c_str(), nullptr);