Clang-tidy-14 fixes
Do as the robot commands. All changes made automatically by tidy.
Tested: (Thanks Zhikui)
Downloaded and run on system. Sensors scan normally.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I752f37c9e7a95aa3be8e6980ba6e4b2b48b3395a
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index 2f737af..c4c4cd8 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -207,8 +207,9 @@
if (findEthIndex != baseConfiguration->second.end() &&
findName != baseConfiguration->second.end())
{
- auto* pEthIndex = std::get_if<uint64_t>(&findEthIndex->second);
- auto* pName = std::get_if<std::string>(&findName->second);
+ const auto* pEthIndex =
+ std::get_if<uint64_t>(&findEthIndex->second);
+ const auto* pName = std::get_if<std::string>(&findName->second);
if (pEthIndex != nullptr && pName != nullptr)
{
lanInfoMap[*pEthIndex] = *pName;
@@ -221,7 +222,7 @@
}
}
- if (lanInfoMap.size() == 0)
+ if (lanInfoMap.empty())
{
std::cerr << "can't find matched NIC name. \n";
}
@@ -281,8 +282,8 @@
bool oldLanConnected = findLanStatus->second;
// get lan info from map
- std::string lanInfo = "";
- if (lanInfoMap.size() > 0)
+ std::string lanInfo;
+ if (!lanInfoMap.empty())
{
auto findLanInfo = lanInfoMap.find(ethNum);
if (findLanInfo == lanInfoMap.end())
@@ -307,8 +308,8 @@
if (oldLanConnected != newLanConnected)
{
std::string strEthNum = "eth" + std::to_string(ethNum) + lanInfo;
- auto strState = newLanConnected ? "connected" : "lost";
- auto strMsgId =
+ const auto* strState = newLanConnected ? "connected" : "lost";
+ const auto* strMsgId =
newLanConnected ? "OpenBMC.0.1.LanRegained" : "OpenBMC.0.1.LanLost";
lg2::info("{ETHDEV} LAN leash {STATE}", "ETHDEV", strEthNum, "STATE",