summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-10-20 09:44:19 -0700
committerPatrick Venture <venture@google.com>2018-10-20 09:47:20 -0700
commitde8ea5689932dfa266c3ac47dde35c4bdd450eaf (patch)
treebf1f81cae7e41af218d5b51855e14fc49008568e
parent234b735df51ab47eecb6ff3a33a63923059816bc (diff)
downloadipmi-fru-parser-de8ea5689932dfa266c3ac47dde35c4bdd450eaf.zip
ipmi-fru-parser-de8ea5689932dfa266c3ac47dde35c4bdd450eaf.tar.gz
style: move getFRUValue into anonymous namespace
Move getFRUValue into anonymous namespace. A later step may move this into a global scope to enable testing, or it may be replaced by an interface. Change-Id: Ie4299ab713a455dd8c18b91c842ded5dfc26e85b Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r--writefrudata.cpp114
1 files changed, 57 insertions, 57 deletions
diff --git a/writefrudata.cpp b/writefrudata.cpp
index b89e019..42ebd67 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -48,6 +48,63 @@ int cleanupError(FILE* fru_fp, fru_area_vec_t& fru_area_vec)
return -1;
}
+//------------------------------------------------------------------------
+// Gets the value of the key from the fru dictionary of the given section.
+// FRU dictionary is parsed fru data for all the sections.
+//------------------------------------------------------------------------
+std::string getFRUValue(const std::string& section, const std::string& key,
+ const std::string& delimiter, IPMIFruInfo& fruData)
+{
+
+ auto minIndexValue = 0;
+ auto maxIndexValue = 0;
+ std::string fruValue = "";
+
+ if (section == "Board")
+ {
+ minIndexValue = OPENBMC_VPD_KEY_BOARD_MFG_DATE;
+ maxIndexValue = OPENBMC_VPD_KEY_BOARD_MAX;
+ }
+ else if (section == "Product")
+ {
+ minIndexValue = OPENBMC_VPD_KEY_PRODUCT_MFR;
+ maxIndexValue = OPENBMC_VPD_KEY_PRODUCT_MAX;
+ }
+ else if (section == "Chassis")
+ {
+ minIndexValue = OPENBMC_VPD_KEY_CHASSIS_TYPE;
+ maxIndexValue = OPENBMC_VPD_KEY_CHASSIS_MAX;
+ }
+
+ auto first = fruData.cbegin() + minIndexValue;
+ auto last = first + (maxIndexValue - minIndexValue) + 1;
+
+ auto itr =
+ std::find_if(first, last, [&key](auto& e) { return key == e.first; });
+
+ if (itr != last)
+ {
+ fruValue = itr->second;
+ }
+
+ // if the key is custom property then the value could be in two formats.
+ // 1) custom field 2 = "value".
+ // 2) custom field 2 = "key:value".
+ // if delimiter length = 0 i.e custom field 2 = "value"
+
+ constexpr auto customProp = "Custom Field";
+ if (key.find(customProp) != std::string::npos)
+ {
+ if (delimiter.length() > 0)
+ {
+ size_t delimiterpos = fruValue.find(delimiter);
+ if (delimiterpos != std::string::npos)
+ fruValue = fruValue.substr(delimiterpos + 1);
+ }
+ }
+ return fruValue;
+}
+
} // namespace
//----------------------------------------------------------------
@@ -225,63 +282,6 @@ int verify_fru_data(const uint8_t* data, const size_t len)
return EXIT_SUCCESS;
}
-//------------------------------------------------------------------------
-// Gets the value of the key from the fru dictionary of the given section.
-// FRU dictionary is parsed fru data for all the sections.
-//------------------------------------------------------------------------
-
-std::string getFRUValue(const std::string& section, const std::string& key,
- const std::string& delimiter, IPMIFruInfo& fruData)
-{
-
- auto minIndexValue = 0;
- auto maxIndexValue = 0;
- std::string fruValue = "";
-
- if (section == "Board")
- {
- minIndexValue = OPENBMC_VPD_KEY_BOARD_MFG_DATE;
- maxIndexValue = OPENBMC_VPD_KEY_BOARD_MAX;
- }
- else if (section == "Product")
- {
- minIndexValue = OPENBMC_VPD_KEY_PRODUCT_MFR;
- maxIndexValue = OPENBMC_VPD_KEY_PRODUCT_MAX;
- }
- else if (section == "Chassis")
- {
- minIndexValue = OPENBMC_VPD_KEY_CHASSIS_TYPE;
- maxIndexValue = OPENBMC_VPD_KEY_CHASSIS_MAX;
- }
-
- auto first = fruData.cbegin() + minIndexValue;
- auto last = first + (maxIndexValue - minIndexValue) + 1;
-
- auto itr =
- std::find_if(first, last, [&key](auto& e) { return key == e.first; });
-
- if (itr != last)
- {
- fruValue = itr->second;
- }
-
- // if the key is custom property then the value could be in two formats.
- // 1) custom field 2 = "value".
- // 2) custom field 2 = "key:value".
- // if delimiter length = 0 i.e custom field 2 = "value"
-
- constexpr auto customProp = "Custom Field";
- if (key.find(customProp) != std::string::npos)
- {
- if (delimiter.length() > 0)
- {
- size_t delimiterpos = fruValue.find(delimiter);
- if (delimiterpos != std::string::npos)
- fruValue = fruValue.substr(delimiterpos + 1);
- }
- }
- return fruValue;
-}
// Get the inventory service from the mapper.
auto getService(sdbusplus::bus::bus& bus, const std::string& intf,
const std::string& path)
OpenPOWER on IntegriCloud