Fix threshold checking

Fix a bug of undefined threshold value, if threshold is not defined
then there will not be threshold monitoring

This is just fixing current issue but code can be enhanced for better
handling, will modify it later.

Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
Change-Id: I8f54552f202ac1aeee14ad655d7846446f516bc4
diff --git a/healthMonitor.cpp b/healthMonitor.cpp
index a04ff37..4981cd6 100644
--- a/healthMonitor.cpp
+++ b/healthMonitor.cpp
@@ -16,6 +16,7 @@
 }
 
 static constexpr bool DEBUG = false;
+static constexpr uint8_t defaultHighThreshold = 100;
 
 namespace phosphor
 {
@@ -179,7 +180,7 @@
 
 void HealthSensor::checkSensorThreshold(const double value)
 {
-    if (value > sensorConfig.criticalHigh)
+    if (sensorConfig.criticalHigh && (value > sensorConfig.criticalHigh))
     {
         if (!CriticalInterface::criticalAlarmHigh())
         {
@@ -201,6 +202,10 @@
                                  entry("NAME = %s", sensorConfig.name.c_str()));
         }
 
+        /* if warning high value is not set then return */
+        if (!sensorConfig.warningHigh)
+            return;
+
         if ((value > sensorConfig.warningHigh) &&
             (!WarningInterface::warningAlarmHigh()))
         {
@@ -318,15 +323,16 @@
         auto criticalData = threshold.value("Critical", empty);
         if (!criticalData.empty())
         {
-            cfg.criticalHigh = criticalData.value("Value", 0);
+            cfg.criticalHigh =
+                criticalData.value("Value", defaultHighThreshold);
             cfg.criticalLog = criticalData.value("Log", true);
             cfg.criticalTgt = criticalData.value("Target", "");
         }
         auto warningData = threshold.value("Warning", empty);
         if (!warningData.empty())
         {
-            cfg.warningHigh = warningData.value("Value", 0);
-            cfg.warningLog = warningData.value("Log", true);
+            cfg.warningHigh = warningData.value("Value", defaultHighThreshold);
+            cfg.warningLog = warningData.value("Log", false);
             cfg.warningTgt = warningData.value("Target", "");
         }
     }