dbus-sdr: Support NaN thresholds

It is possible that the threshold interface (Warning or Critical) is
present, but one of its thresholds is not set. In this case IPMI should
report 'na' for this threshold.

Before:
P0 VDD CORE      | na | Amps | na | na | 0.000 | na | na | 49.980 | na

After:
P0 VDD CORE      | na | Amps | na | na | na    | na | na | 49.980 | na

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Change-Id: Ia524d56d0d4944a53973edb8a8a5c34ad848053a
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index 91978c8..4e971b3 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -223,12 +223,18 @@
         if (lower != critical->second.end())
         {
             double value = std::visit(VariantToDoubleVisitor(), lower->second);
-            min = std::min(value, min);
+            if (std::isfinite(value))
+            {
+                min = std::min(value, min);
+            }
         }
         if (upper != critical->second.end())
         {
             double value = std::visit(VariantToDoubleVisitor(), upper->second);
-            max = std::max(value, max);
+            if (std::isfinite(value))
+            {
+                max = std::max(value, max);
+            }
         }
     }
     if (warning != sensorMap.end())
@@ -239,12 +245,18 @@
         if (lower != warning->second.end())
         {
             double value = std::visit(VariantToDoubleVisitor(), lower->second);
-            min = std::min(value, min);
+            if (std::isfinite(value))
+            {
+                min = std::min(value, min);
+            }
         }
         if (upper != warning->second.end())
         {
             double value = std::visit(VariantToDoubleVisitor(), upper->second);
-            max = std::max(value, max);
+            if (std::isfinite(value))
+            {
+                max = std::max(value, max);
+            }
         }
     }
 }
@@ -1110,15 +1122,21 @@
 
                 double value =
                     std::visit(VariantToDoubleVisitor(), warningHigh->second);
-                resp.warningHigh = scaleIPMIValueFromDouble(
-                    value, mValue, rExp, bValue, bExp, bSigned);
+                if (std::isfinite(value))
+                {
+                    resp.warningHigh = scaleIPMIValueFromDouble(
+                        value, mValue, rExp, bValue, bExp, bSigned);
+                }
             }
             if (warningLow != warningMap.end())
             {
                 double value =
                     std::visit(VariantToDoubleVisitor(), warningLow->second);
-                resp.warningLow = scaleIPMIValueFromDouble(
-                    value, mValue, rExp, bValue, bExp, bSigned);
+                if (std::isfinite(value))
+                {
+                    resp.warningLow = scaleIPMIValueFromDouble(
+                        value, mValue, rExp, bValue, bExp, bSigned);
+                }
             }
         }
         if (criticalInterface != sensorMap.end())
@@ -1132,15 +1150,21 @@
             {
                 double value =
                     std::visit(VariantToDoubleVisitor(), criticalHigh->second);
-                resp.criticalHigh = scaleIPMIValueFromDouble(
-                    value, mValue, rExp, bValue, bExp, bSigned);
+                if (std::isfinite(value))
+                {
+                    resp.criticalHigh = scaleIPMIValueFromDouble(
+                        value, mValue, rExp, bValue, bExp, bSigned);
+                }
             }
             if (criticalLow != criticalMap.end())
             {
                 double value =
                     std::visit(VariantToDoubleVisitor(), criticalLow->second);
-                resp.criticalLow = scaleIPMIValueFromDouble(
-                    value, mValue, rExp, bValue, bExp, bSigned);
+                if (std::isfinite(value))
+                {
+                    resp.criticalLow = scaleIPMIValueFromDouble(
+                        value, mValue, rExp, bValue, bExp, bSigned);
+                }
             }
         }
     }