Corrects bug in using boost::container erase()
Shawn pointed out an existing bug using boost::container erase()
described here: https://gerrit.openbmc-project.xyz/c/openbmc/\
dbus-sensors/+/43410/70..74/src/IIOMain.cpp#196 This fixes that bug.
Tested: on Everest's Storm King Op Panels with busctl introspect \
--no-pager xyz.openbmc_project.HwmonTempSensor /xyz/openbmc_project/\
sensors/temperature/Ambient_0_Temp Results functioning properly and
consistent with location of the systems.
Signed-off-by: Bruce Mitchell <bruce.mitchell@linux.vnet.ibm.com>
Change-Id: Ibe5293c389cdd5796755e6d5bf41000d4c6d1c80
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index 2d39f97..d4e4e27 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -188,16 +188,17 @@
if (!firstScan && findSensor != sensors.end())
{
bool found = false;
- for (auto it = sensorsChanged->begin();
- it != sensorsChanged->end(); it++)
+ auto it = sensorsChanged->begin();
+ while (it != sensorsChanged->end())
{
if (boost::ends_with(*it, findSensor->second->name))
{
- sensorsChanged->erase(it);
+ it = sensorsChanged->erase(it);
findSensor->second = nullptr;
found = true;
break;
}
+ ++it;
}
if (!found)
{