Remove reinitialisation of error code
The commit removes re-initialization of all the error code variables
before calling the utility API as utility APIs will internally reset
the error code before setting it in case of any failure.
This will remove the overhead of caller to re-init the variable before
calling any utility API hence reducing the chance of any miss and
undefined behavior.
Change-Id: I426bbb6c17484a3da12dc6ddd2bccfaefbfc0bf5
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp
index 48d4dc8..a712775 100644
--- a/vpd-manager/src/worker.cpp
+++ b/vpd-manager/src/worker.cpp
@@ -588,8 +588,6 @@
propValuePair.value().get<std::string>() +
" ,error : " +
commonUtility::getErrCodeMsg(l_errCode));
-
- l_errCode = 0;
}
propertyMap.emplace(property, value);
@@ -605,8 +603,6 @@
logging::logMessage(
"Failed to insert value into map, error : " +
commonUtility::getErrCodeMsg(l_errCode));
-
- l_errCode = 0;
}
}
else
@@ -662,8 +658,6 @@
"Failed to get encoded keyword value for : ") +
keyword + std::string(", error : ") +
commonUtility::getErrCodeMsg(l_errCode));
-
- l_errCode = 0;
}
propertyMap.emplace(property, encoded);
@@ -690,8 +684,6 @@
"Failed to get encoded keyword value for : ") +
keyword + std::string(", error : ") +
commonUtility::getErrCodeMsg(l_errCode));
-
- l_errCode = 0;
}
propertyMap.emplace(property, encodedValue);
@@ -711,8 +703,6 @@
"Failed to get encoded keyword value for : " +
keyword + ", error : " +
commonUtility::getErrCodeMsg(l_errCode));
-
- l_errCode = 0;
}
propertyMap.emplace(property, encodedValue);
@@ -738,8 +728,6 @@
{
logging::logMessage("Failed to insert value into map, error : " +
commonUtility::getErrCodeMsg(l_errCode));
-
- l_errCode = 0;
}
}
}
@@ -1187,6 +1175,7 @@
const std::string& i_flagToProcess,
uint16_t& i_errCode)
{
+ i_errCode = 0;
if (i_vpdFilePath.empty() || i_flagToProcess.empty())
{
i_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -1285,7 +1274,6 @@
}
}
- l_errCode = 0;
if (!jsonUtility::executeBaseAction(m_parsedJson, "postAction",
i_vpdFruPath, i_flagToProcess,
l_errCode))
@@ -1319,7 +1307,6 @@
if (jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath,
"preAction", "collection", l_errCode))
{
- l_errCode = 0;
isPreActionRequired = true;
if (!processPreAction(i_vpdFilePath, "collection", l_errCode))
{
@@ -1367,8 +1354,6 @@
// any post action in the flow of collection.
// Note: Don't change the order, post action needs to be processed only
// after collection for FRU is successfully done.
- l_errCode = 0;
-
if (jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath,
"postAction", "collection",
l_errCode))
@@ -1583,7 +1568,6 @@
"], error : " + commonUtility::getErrCodeMsg(l_errCode));
}
- l_errCode = 0;
std::string l_invPath = jsonUtility::getInventoryObjPathFromJson(
m_parsedJson, i_vpdFilePath, l_errCode);
@@ -1802,7 +1786,6 @@
for (const auto& [l_objectPath, l_serviceInterfaceMap] :
l_subTreeMap)
{
- l_errCode = 0;
types::InterfaceMap l_interfaceMap;
vpdSpecificUtility::resetDataUnderPIM(
l_objectPath, l_interfaceMap, l_errCode);
@@ -1819,7 +1802,6 @@
std::move(l_interfaceMap));
}
- l_errCode = 0;
types::InterfaceMap l_interfaceMap;
vpdSpecificUtility::resetDataUnderPIM(
i_dbusObjPath, l_interfaceMap, l_errCode);
@@ -1838,8 +1820,6 @@
throw std::runtime_error("Call to PIM failed.");
}
- l_errCode = 0;
-
if (jsonUtility::isActionRequired(m_parsedJson, l_fruPath,
"postAction", "deletion",
l_errCode))
@@ -2106,7 +2086,6 @@
"], error : " + commonUtility::getErrCodeMsg(l_errCode));
}
- l_errCode = 0;
bool isFruReplaceableAtRuntime =
jsonUtility::isFruReplaceableAtRuntime(m_parsedJson, l_fruPath,
l_errCode);