summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2018-11-07 16:35:40 -0600
committerMatt Spinler <spinler@us.ibm.com>2018-11-26 21:17:51 +0000
commit153494e0dfb6cbc47ce8506ded4f0fd59f9436c4 (patch)
tree418e2f5521c46e041fdf6b2b9d207b122846f902
parentaf1aa756a11fff49bc459a826741232f061a0d63 (diff)
downloadphosphor-objmgr-153494e0dfb6cbc47ce8506ded4f0fd59f9436c4.tar.gz
phosphor-objmgr-153494e0dfb6cbc47ce8506ded4f0fd59f9436c4.zip
mapper: Don't return the input path in GetSubTree
In both GetSubTree and GetSubTreePaths, don't return the input path as a result. This matches the behavior of the original mapper. Change-Id: Ib4bab71a6001e9a18ab2565b0e2d708b034f8c44 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rw-r--r--src/main.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 2643eed..9084d0d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -917,9 +917,8 @@ int main(int argc, char** argv)
});
iface->register_method(
- "GetSubTree",
- [&interface_map](const std::string& req_path, int32_t depth,
- std::vector<std::string>& interfaces) {
+ "GetSubTree", [&interface_map](std::string& req_path, int32_t depth,
+ std::vector<std::string>& interfaces) {
if (depth <= 0)
{
depth = std::numeric_limits<int32_t>::max();
@@ -928,9 +927,20 @@ int main(int argc, char** argv)
std::sort(interfaces.begin(), interfaces.end());
std::vector<interface_map_type::value_type> ret;
+ if (req_path.size() > 1 && req_path.back() == '/')
+ {
+ req_path.pop_back();
+ }
+
for (auto& object_path : interface_map)
{
auto& this_path = object_path.first;
+
+ if (this_path == req_path)
+ {
+ continue;
+ }
+
if (boost::starts_with(this_path, req_path))
{
// count the number of slashes past the search term
@@ -961,7 +971,7 @@ int main(int argc, char** argv)
iface->register_method(
"GetSubTreePaths",
- [&interface_map](const std::string& req_path, int32_t depth,
+ [&interface_map](std::string& req_path, int32_t depth,
std::vector<std::string>& interfaces) {
if (depth <= 0)
{
@@ -970,9 +980,21 @@ int main(int argc, char** argv)
// Interfaces need to be sorted for intersect to function
std::sort(interfaces.begin(), interfaces.end());
std::vector<std::string> ret;
+
+ if (req_path.size() > 1 && req_path.back() == '/')
+ {
+ req_path.pop_back();
+ }
+
for (auto& object_path : interface_map)
{
auto& this_path = object_path.first;
+
+ if (this_path == req_path)
+ {
+ continue;
+ }
+
if (boost::starts_with(this_path, req_path))
{
// count the number of slashes past the search term
OpenPOWER on IntegriCloud