summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2018-11-29 14:54:13 -0600
committerMatt Spinler <spinler@us.ibm.com>2018-11-29 15:05:16 -0600
commit47c09755e5a7e4c998ed9c4e82d82f7ee5cd6f43 (patch)
tree6acd29ac95a7b6ac33121f62231534a718a4af57
parent6a39e8c727efb53b5902904d932c6308eb7f393e (diff)
downloadphosphor-objmgr-47c09755e5a7e4c998ed9c4e82d82f7ee5cd6f43.tar.gz
phosphor-objmgr-47c09755e5a7e4c998ed9c4e82d82f7ee5cd6f43.zip
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>
-rw-r--r--src/main.cpp18
1 files changed, 10 insertions, 8 deletions
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 splitArgs(const std::string& stringArgs,
}
}
-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 @@ void addSubtreeResult(
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 @@ int main(int argc, char** argv)
interface_map.second.begin(),
interface_map.second.end()))
{
- ret.emplace_back(object_path);
+ addObjectMapResult(ret, this_path,
+ interface_map);
break;
}
}
@@ -901,7 +902,8 @@ int main(int argc, char** argv)
interface_map.second.end()) ||
interfaces.empty())
{
- addSubtreeResult(ret, this_path, interface_map);
+ addObjectMapResult(ret, this_path,
+ interface_map);
}
}
}
OpenPOWER on IntegriCloud