Start using sdbusplus::message::filename()
Lots of code gets checked in that does this path checking incorrectly.
So much so, that we have it documented in COMMON_ERRORS.md, yet, we
persist. This patchset starts using the new object_path::filename()
method that was added recently to sdbusplus. Overall, it deletes code,
and makes for a much better developer experience.
Tested:
Pulled down several endpoints and verified that filename() method works
properly, and the collections are returned as expected.
curl -vvvv --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/AccountService/Accounts
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ief1e0584394fb139678d3453265f7011bc931f3c
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 4975a37..98a0808 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -442,14 +442,12 @@
uint64_t size = 0;
entriesArray.push_back({});
nlohmann::json& thisEntry = entriesArray.back();
- const std::string& path =
- static_cast<const std::string&>(object.first);
- std::size_t lastPos = path.rfind('/');
- if (lastPos == std::string::npos)
+
+ std::string entryID = object.first.filename();
+ if (entryID.empty())
{
continue;
}
- std::string entryID = path.substr(lastPos + 1);
for (auto& interfaceMap : object.second)
{
@@ -842,12 +840,13 @@
for (const std::string& path : subTreePaths)
{
- std::size_t pos = path.rfind('/');
- if (pos != std::string::npos)
+ sdbusplus::message::object_path objPath(path);
+ std::string logID = objPath.filename();
+ if (logID.empty())
{
- std::string logID = path.substr(pos + 1);
- deleteDumpEntry(asyncResp, logID, dumpType);
+ continue;
}
+ deleteDumpEntry(asyncResp, logID, dumpType);
}
},
"xyz.openbmc_project.ObjectMapper",