Filter results of GetAncestors
As with GetSubTree, GetAncestors should only return the object
paths with their services and interfaces for just the services
that implement the interfaces passed into the function.
The previous code was returning all services/interfaces for an
object path that was an ancestor instead of just the services
that actually provided that interface.
Tested: Calling GetAncestors on /xyz/openbmc_project/ with
the ObjectManager interface filter would now only
return ancestors that actually had the ObjectManager
interface.
Change-Id: Ie80e78ac76a6fe9d474e6b34bc4555dca490ac51
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/src/main.cpp b/src/main.cpp
index 3ee6362..e8928a9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -501,22 +501,22 @@
}
}
-void addSubtreeResult(
- std::vector<interface_map_type::value_type>& subtree,
+void addObjectMapResult(
+ std::vector<interface_map_type::value_type>& objectMap,
const std::string& objectPath,
const std::pair<std::string, boost::container::flat_set<std::string>>&
interfaceMap)
{
// Adds an object path/service name/interface list entry to
- // the results of GetSubTree.
+ // the results of GetSubTree and GetAncestors.
// If an entry for the object path already exists, just add the
// service name and interfaces to that entry, otherwise create
// a new entry.
auto entry = std::find_if(
- subtree.begin(), subtree.end(),
+ objectMap.begin(), objectMap.end(),
[&objectPath](const auto& i) { return objectPath == i.first; });
- if (entry != subtree.end())
+ if (entry != objectMap.end())
{
entry->second.emplace(interfaceMap);
}
@@ -525,7 +525,7 @@
interface_map_type::value_type object;
object.first = objectPath;
object.second.emplace(interfaceMap);
- subtree.push_back(object);
+ objectMap.push_back(object);
}
}
@@ -806,7 +806,8 @@
interface_map.second.begin(),
interface_map.second.end()))
{
- ret.emplace_back(object_path);
+ addObjectMapResult(ret, this_path,
+ interface_map);
break;
}
}
@@ -901,7 +902,8 @@
interface_map.second.end()) ||
interfaces.empty())
{
- addSubtreeResult(ret, this_path, interface_map);
+ addObjectMapResult(ret, this_path,
+ interface_map);
}
}
}