zone: remove static_cast in float-to-int conversion
It is recommended to use library functions for conversions between
floating point and integers. Replace static_cast (which performs
truncation) with lround (which rounds).
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ied6633869b685d63abdbdaa249332e69b18b439b
diff --git a/control/zone.hpp b/control/zone.hpp
index 36fdb54..c949228 100644
--- a/control/zone.hpp
+++ b/control/zone.hpp
@@ -2,6 +2,7 @@
#include <algorithm>
#include <cassert>
#include <chrono>
+#include <cmath>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/event.hpp>
#include <vector>
@@ -254,7 +255,7 @@
std::is_same_v<V, double>)
{
val = val * 1000;
- value = static_cast<T>(val);
+ value = std::lround(val);
}
// If the type configured matches the sensor value
// property's type, just return the value as its