hwmontemp: Fix object type being passed to ctors
The Sensor base class is now tacking on the
'xyz.openbmc_project.Configuration' prefix to the objectType argument
passed into its constructor. But in createSensors() the value passed
into the constructor was already the full interface name taken from the
buildSensorConfigMap() output, so the prefix ended up being in the
objectType member variable twice.
This was causing the InterfacesRemoved handler to not find an interface
match when entity-manager removed interfaces, leaving sensors on D-Bus
for hardware that was no longer in the system.
Fix it by stripping off all but the last segment before passing it to
the sensor object constructor.
Tested:
Sensors are now removed from D-Bus when the corresponding objects are
removed from entity-manager.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I3312a6cddbe2b175b89f8566d5c9359b7c2df201
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index 40451e1..557fe3c 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -423,7 +423,12 @@
}
const SensorData& sensorData = findSensorCfg->second.sensorData;
- const std::string& sensorType = findSensorCfg->second.interface;
+ std::string sensorType = findSensorCfg->second.interface;
+ auto pos = sensorType.find_last_of('.');
+ if (pos != std::string::npos)
+ {
+ sensorType = sensorType.substr(pos + 1);
+ }
const SensorBaseConfigMap& baseConfigMap =
findSensorCfg->second.config;
std::vector<std::string>& hwmonName = findSensorCfg->second.name;