Add index for duplicate fru names
Add index so the dbus path is unique.
Change-Id: Ie02ede73799a79b4b3da8a6eab082a0a2291c710
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/FruDevice.cpp b/src/FruDevice.cpp
index cb268a9..86806ba 100644
--- a/src/FruDevice.cpp
+++ b/src/FruDevice.cpp
@@ -383,14 +383,28 @@
productName = "/xyz/openbmc_project/FruDevice/" + productName;
// avoid duplicates by checking to see if on a mux
- if (bus > 0 && isMuxBus(bus))
+ if (bus > 0)
{
+ size_t index = 0;
for (auto const &busObj : dbusObjectMap)
{
- if ((address == busObj.first.second) &&
- (busObj.second->object_name == productName))
+ if ((busObj.second->object_name == productName))
{
- continue;
+ if (isMuxBus(bus) && address == busObj.first.second)
+ {
+ continue;
+ }
+ // add underscore _index for the same object path on dbus
+ std::string strIndex = std::to_string(index);
+ if (index > 0)
+ {
+ productName.substr(0, productName.size() - strIndex.size());
+ }
+ else
+ {
+ productName += "_";
+ }
+ productName += std::to_string(index++);
}
}
}