Fix wrong threshold report
For the sensor that does not support the threshold values such as
WarningLow, WarningHigh, CriticalLow, CriticalHigh.
These value should be 'na'.
Tested:
1. Get sensor info via ipmi command
ipmitool sensor get S1_SOC_Temp
...
Lower Non-Recoverable : na
Lower Critical : na
Lower Non-Critical : na
Upper Non-Critical : na
Upper Critical : 105.000
....
Signed-off-by: Hieu Huynh <hieuh@os.amperecomputing.com>
Change-Id: Ia366a906300c289ea94110b87fff92bca7e2b865
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 1a24c42..30cee8b 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -692,10 +692,12 @@
warningThreshIntf, warnThresholds);
if (!ec)
{
- double warnLow = std::visit(ipmi::VariantToDoubleVisitor(),
- warnThresholds["WarningLow"]);
- double warnHigh = std::visit(ipmi::VariantToDoubleVisitor(),
- warnThresholds["WarningHigh"]);
+ double warnLow = ipmi::mappedVariant<double>(
+ warnThresholds, "WarningLow",
+ std::numeric_limits<double>::quiet_NaN());
+ double warnHigh = ipmi::mappedVariant<double>(
+ warnThresholds, "WarningHigh",
+ std::numeric_limits<double>::quiet_NaN());
if (std::isfinite(warnLow))
{
@@ -721,10 +723,12 @@
criticalThreshIntf, critThresholds);
if (!ec)
{
- double critLow = std::visit(ipmi::VariantToDoubleVisitor(),
- critThresholds["CriticalLow"]);
- double critHigh = std::visit(ipmi::VariantToDoubleVisitor(),
- critThresholds["CriticalHigh"]);
+ double critLow = ipmi::mappedVariant<double>(
+ critThresholds, "CriticalLow",
+ std::numeric_limits<double>::quiet_NaN());
+ double critHigh = ipmi::mappedVariant<double>(
+ critThresholds, "CriticalHigh",
+ std::numeric_limits<double>::quiet_NaN());
if (std::isfinite(critLow))
{