Follow secure coding standards for interactions with the mapper
This patchset updates phosphor-time-manager to follow secure coding
guidelines when interacting with the mapper. Specifically, it replaces
uses of std::map with std::vector<std::pair<>>, which should net some
small performance wins. This change also causes time-manager to
properly enumerate each response.
Tested-By:
Built with changeset, and verified via d-feet that
/xyz/openbmc_project/time/host and /xyz/openbmc_project/time/bmc were
present, and verified reading of the "Elapsed" parameter returned the
expected time result.
Change-Id: If4329d533641595cf0b50c4e50e2dda69b299f52
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/utils.cpp b/utils.cpp
index 25b8f8c..778487f 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -47,7 +47,8 @@
MethodError::MISC({}));
}
- std::map<std::string, std::vector<std::string>> mapperResponse;
+ std::vector<std::pair<std::string, std::vector<std::string>>>
+ mapperResponse;
mapperResponseMsg.read(mapperResponse);
if (mapperResponse.empty())
{
@@ -57,8 +58,10 @@
MethodError::INTERFACE(interface),
MethodError::MISC("Error reading mapper response"));
}
-
- return mapperResponse.begin()->first;
+ if (mapperResponse.size() < 1){
+ return "";
+ }
+ return mapperResponse[0].first;
}
Mode strToMode(const std::string& mode)