Set unset threshold values to NaN

Currently unset thresholds are set to 0. But correct value for unset
thresholds is NaN.

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Change-Id: I1fbf120d5ea4af7e470fa4d9b7d77c6a14a15b96
diff --git a/healthMonitor.cpp b/healthMonitor.cpp
index bddbb3f..9024048 100644
--- a/healthMonitor.cpp
+++ b/healthMonitor.cpp
@@ -312,7 +312,8 @@
 
 void HealthSensor::checkSensorThreshold(const double value)
 {
-    if (sensorConfig.criticalHigh && (value > sensorConfig.criticalHigh))
+    if (std::isfinite(sensorConfig.criticalHigh) &&
+        (value > sensorConfig.criticalHigh))
     {
         if (!CriticalInterface::criticalAlarmHigh())
         {
@@ -322,24 +323,22 @@
                     "ASSERT: sensor {SENSOR} is above the upper threshold critical high",
                     "SENSOR", sensorConfig.name);
         }
+        return;
     }
-    else
+
+    if (CriticalInterface::criticalAlarmHigh())
     {
-        if (CriticalInterface::criticalAlarmHigh())
-        {
-            CriticalInterface::criticalAlarmHigh(false);
-            if (sensorConfig.criticalLog)
-                info(
-                    "DEASSERT: sensor {SENSOR} is under the upper threshold critical high",
-                    "SENSOR", sensorConfig.name);
-        }
+        CriticalInterface::criticalAlarmHigh(false);
+        if (sensorConfig.criticalLog)
+            info(
+                "DEASSERT: sensor {SENSOR} is under the upper threshold critical high",
+                "SENSOR", sensorConfig.name);
+    }
 
-        /* if warning high value is not set then return */
-        if (!sensorConfig.warningHigh)
-            return;
-
-        if ((value > sensorConfig.warningHigh) &&
-            (!WarningInterface::warningAlarmHigh()))
+    if (std::isfinite(sensorConfig.warningHigh) &&
+        (value > sensorConfig.warningHigh))
+    {
+        if (!WarningInterface::warningAlarmHigh())
         {
             WarningInterface::warningAlarmHigh(true);
             if (sensorConfig.warningLog)
@@ -347,15 +346,16 @@
                     "ASSERT: sensor {SENSOR} is above the upper threshold warning high",
                     "SENSOR", sensorConfig.name);
         }
-        else if ((value <= sensorConfig.warningHigh) &&
-                 (WarningInterface::warningAlarmHigh()))
-        {
-            WarningInterface::warningAlarmHigh(false);
-            if (sensorConfig.warningLog)
-                info(
-                    "DEASSERT: sensor {SENSOR} is under the upper threshold warning high",
-                    "SENSOR", sensorConfig.name);
-        }
+        return;
+    }
+
+    if (WarningInterface::warningAlarmHigh())
+    {
+        WarningInterface::warningAlarmHigh(false);
+        if (sensorConfig.warningLog)
+            info(
+                "DEASSERT: sensor {SENSOR} is under the upper threshold warning high",
+                "SENSOR", sensorConfig.name);
     }
 }
 
diff --git a/healthMonitor.hpp b/healthMonitor.hpp
index 062c840..d327cf0 100644
--- a/healthMonitor.hpp
+++ b/healthMonitor.hpp
@@ -11,6 +11,7 @@
 #include <xyz/openbmc_project/Sensor/Value/server.hpp>
 
 #include <deque>
+#include <limits>
 #include <map>
 #include <string>
 
@@ -67,8 +68,8 @@
     std::string name;
     uint16_t freq;
     uint16_t windowSize;
-    double criticalHigh;
-    double warningHigh;
+    double criticalHigh = std::numeric_limits<double>::quiet_NaN();
+    double warningHigh = std::numeric_limits<double>::quiet_NaN();
     bool criticalLog;
     bool warningLog;
     std::string criticalTgt;