Update json utility methods

Error code is initialized to 0 for each json utility function, this has
been done to remove caller's over head to set the variable before each
call, missing which can cause error code from previous call to pop up
resulting in misleading error logging.

Change-Id: I1f8d0c5634cfda23d59003ce519b8e16bd50fdf5
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/include/utility/json_utility.hpp b/vpd-manager/include/utility/json_utility.hpp
index 8463ffb..aa1dd9e 100644
--- a/vpd-manager/include/utility/json_utility.hpp
+++ b/vpd-manager/include/utility/json_utility.hpp
@@ -61,6 +61,7 @@
                            const std::string& i_vpdFilePath,
                            uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_vpdFilePath.empty() || (i_sysCfgJsonObj.empty()) ||
         (!i_sysCfgJsonObj.contains("frus")))
     {
@@ -104,6 +105,7 @@
 inline nlohmann::json getParsedJson(const std::string& pathToJson,
                                     uint16_t& o_errCode) noexcept
 {
+    o_errCode = 0;
     if (pathToJson.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -159,6 +161,7 @@
     const nlohmann::json& i_sysCfgJsonObj, const std::string& i_vpdPath,
     uint16_t& o_errCode) noexcept
 {
+    o_errCode = 0;
     if (i_vpdPath.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -218,6 +221,7 @@
     const nlohmann::json& i_parsedConfigJson, const std::string& i_vpdFilePath,
     const std::string& i_flagToProcess, uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_parsedConfigJson.empty() || i_vpdFilePath.empty() ||
         i_flagToProcess.empty())
     {
@@ -295,6 +299,7 @@
     const std::string& i_baseAction, const std::string& i_flagToProcess,
     uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_vpdFilePath.empty() || i_parsedConfigJson.empty() ||
         i_baseAction.empty() || i_flagToProcess.empty())
     {
@@ -345,6 +350,7 @@
     const std::string& i_baseAction, const std::string& i_flagToProcess,
     uint16_t& o_errCode)
 {
+    o_errCode = 0;
     std::string l_presencePinName;
     try
     {
@@ -444,6 +450,7 @@
     const std::string& i_baseAction, const std::string& i_flagToProcess,
     uint16_t& o_errCode)
 {
+    o_errCode = 0;
     std::string l_pinName;
     try
     {
@@ -535,6 +542,7 @@
     const std::string& i_vpdFilePath, const std::string& i_flagToProcess,
     uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_flagToProcess.empty() || i_action.empty() || i_vpdFilePath.empty() ||
         !i_parsedConfigJson.contains("frus"))
     {
@@ -604,6 +612,7 @@
     const nlohmann::json& i_sysCfgJsonObj, const std::string& i_vpdPath,
     uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_vpdPath.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -661,6 +670,7 @@
                                       const std::string& i_vpdPath,
                                       uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_vpdPath.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -715,6 +725,7 @@
 inline bool isBackupAndRestoreRequired(const nlohmann::json& i_sysCfgJsonObj,
                                        uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_sysCfgJsonObj.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -753,6 +764,7 @@
                              const std::string& i_action,
                              const std::string& i_flowFlag, uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_vpdFruPath.empty() || i_action.empty() || i_flowFlag.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -799,6 +811,7 @@
     const nlohmann::json& i_sysCfgJsonObj, uint16_t& o_errCode)
 {
     std::vector<std::string> l_gpioPollingRequiredFrusList;
+    o_errCode = 0;
 
     if (i_sysCfgJsonObj.empty())
     {
@@ -964,6 +977,7 @@
                                   const std::string& l_inventoryPath,
                                   uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (l_inventoryPath.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -1017,6 +1031,7 @@
                               const std::string& i_vpdFruPath,
                               uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_vpdFruPath.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -1053,6 +1068,7 @@
                                       const std::string& i_vpdFruPath,
                                       uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_vpdFruPath.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -1092,6 +1108,7 @@
                                       const std::string& i_vpdFruPath,
                                       uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_vpdFruPath.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
@@ -1134,6 +1151,7 @@
     const nlohmann::json& i_sysCfgJsonObj, uint16_t& o_errCode)
 {
     std::vector<std::string> l_frusReplaceableAtStandby;
+    o_errCode = 0;
 
     if (!i_sysCfgJsonObj.contains("frus"))
     {
@@ -1177,13 +1195,13 @@
 inline nlohmann::json getPowerVsJson(const types::BinaryVector& i_imValue,
                                      uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_imValue.empty() || i_imValue.size() < 4)
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;
         return nlohmann::json{};
     }
 
-    o_errCode = 0;
     if ((i_imValue.at(0) == constants::HEX_VALUE_50) &&
         (i_imValue.at(1) == constants::HEX_VALUE_00) &&
         (i_imValue.at(2) == constants::HEX_VALUE_30))
@@ -1234,6 +1252,7 @@
     const nlohmann::json& i_sysCfgJsonObj, uint16_t& o_errCode)
 {
     std::vector<types::Path> l_frusWithPresenceMonitoring;
+    o_errCode = 0;
 
     if (!i_sysCfgJsonObj.contains("frus"))
     {
@@ -1272,6 +1291,7 @@
                                  const std::string& i_vpdFruPath,
                                  uint16_t& o_errCode)
 {
+    o_errCode = 0;
     if (i_vpdFruPath.empty())
     {
         o_errCode = error_code::INVALID_INPUT_PARAMETER;