Fixes for when sensor value is a double
The change to the xyz.openbmc_project.Sensor.Value interface that moves
the Value property to a double from an int64_t has merged, which
uncovered some problems in the code that was trying to detect the type
and handle it accordingly.
This does remove support for the Scale property on the Value interface,
as meson CI won't even compile with it since the double version of it is
empty and so the function has unused parameters, which meson doesn't
like.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I34dc6cc83dae76a879258bf3c6859cd348e4de4d
diff --git a/mainloop.cpp b/mainloop.cpp
index 7303307..b694261 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -76,7 +76,7 @@
Thresholds<CriticalObject>::alarmHi) Thresholds<CriticalObject>::alarmHi =
&CriticalObject::criticalAlarmHigh;
-void updateSensorInterfaces(InterfaceMap& ifaces, int64_t value)
+void updateSensorInterfaces(InterfaceMap& ifaces, SensorValueType value)
{
for (auto& iface : ifaces)
{
@@ -244,12 +244,8 @@
exit(EXIT_FAILURE);
}
auto sensorValue = valueInterface->value();
- int64_t scale = 0;
- // scale the thresholds only if we're using doubles
- if constexpr (std::is_same<SensorValueType, double>::value)
- {
- scale = sensorObj->getScale();
- }
+ int64_t scale = sensorObj->getScale();
+
addThreshold<WarningObject>(sensorSysfsType, std::get<sensorID>(properties),
sensorValue, info, scale);
addThreshold<CriticalObject>(sensorSysfsType,
@@ -418,7 +414,7 @@
input = hwmon::entry::average;
}
- int64_t value;
+ SensorValueType value;
auto& obj = std::get<InterfaceMap>(objInfo);
std::unique_ptr<sensor::Sensor>& sensor = _sensorObjects[sensorSetKey];
diff --git a/mainloop.hpp b/mainloop.hpp
index 6c5b8e0..b3de022 100644
--- a/mainloop.hpp
+++ b/mainloop.hpp
@@ -156,4 +156,4 @@
/** @brief Given a value and map of interfaces, update values and check
* thresholds.
*/
-void updateSensorInterfaces(InterfaceMap& ifaces, int64_t value);
+void updateSensorInterfaces(InterfaceMap& ifaces, SensorValueType value);
diff --git a/sensor.cpp b/sensor.cpp
index 1c91c1e..aa2ff35 100644
--- a/sensor.cpp
+++ b/sensor.cpp
@@ -26,18 +26,6 @@
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-// todo: this can be deleted once we move to double
-// helper class to set the scale on the value iface only when it's available
-template <typename T>
-void setScale(T& iface, int64_t value, double)
-{
-}
-template <typename T>
-void setScale(T& iface, int64_t value, int64_t)
-{
- iface->scale(value);
-}
-
// todo: this can be simplified once we move to the double interface
Sensor::Sensor(const SensorSet::key_type& sensor,
const hwmonio::HwmonIOInterface* ioAccess,
@@ -186,8 +174,6 @@
{
iface->unit(hwmon::getUnit(attrs));
- setScale(iface, hwmon::getScale(attrs), val);
-
_scale = hwmon::getScale(attrs);
}