Google RoT: simplify subtree iteration
Use structured binding declaration to avoid verbose typing of subtree
response.
Tested:
1. code compiles
2. tested on hardware and RoT resources worked as expected.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I22758c196a097cce8e94208085fd59ce1363cefc
diff --git a/include/google/google_service_root.hpp b/include/google/google_service_root.hpp
index 2d43146..2100fab 100644
--- a/include/google/google_service_root.hpp
+++ b/include/google/google_service_root.hpp
@@ -67,22 +67,18 @@
redfish::messages::internalError(asyncResp->res);
return;
}
- // Iterate over all retrieved ObjectPaths.
- for (const std::pair<
- std::string,
- std::vector<std::pair<std::string, std::vector<std::string>>>>&
- object : subtree)
+ for (const auto& [path, services] : subtree)
{
- sdbusplus::message::object_path objPath(object.first);
- if (objPath.filename() != rotId || object.second.empty())
+ sdbusplus::message::object_path objPath(path);
+ if (objPath.filename() != rotId || services.empty())
{
continue;
}
ResolvedEntity resolvedEntity = {
.id = rotId,
- .service = object.second[0].first,
- .object = object.first,
+ .service = services[0].first,
+ .object = path,
.interface = "xyz.openbmc_project.Control.Hoth"};
entityHandler(command, asyncResp, resolvedEntity);
return;