Fix tidy build
This appears to be something tidy is wrong about. The suggestion of
adding math to the struct initializers appears to not compile.
Move the calculation of hysteresisTrigger and hysteresisPublish into the
constructor body itself to avoid the warning.
Change-Id: I833fd12966c69c0e081692d6d40ba0cf1805ead1
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/src/intel-cpu/IntelCPUSensor.cpp b/src/intel-cpu/IntelCPUSensor.cpp
index 5c10967..46ca8ee 100644
--- a/src/intel-cpu/IntelCPUSensor.cpp
+++ b/src/intel-cpu/IntelCPUSensor.cpp
@@ -59,8 +59,7 @@
objServer(objectServer), inputDev(io), waitTimer(io),
nameTcontrol("Tcontrol CPU" + std::to_string(cpuId)), path(path),
privTcontrol(std::numeric_limits<double>::quiet_NaN()),
- dtsOffset(dtsOffset), show(show), pollTime(IntelCPUSensor::sensorPollMs)
-
+ dtsOffset(dtsOffset), show(show)
{
if (show)
{
diff --git a/src/intel-cpu/IntelCPUSensor.hpp b/src/intel-cpu/IntelCPUSensor.hpp
index f51158b..28ea7df 100644
--- a/src/intel-cpu/IntelCPUSensor.hpp
+++ b/src/intel-cpu/IntelCPUSensor.hpp
@@ -51,7 +51,7 @@
double privTcontrol;
double dtsOffset;
bool show;
- size_t pollTime;
+ size_t pollTime{IntelCPUSensor::sensorPollMs};
bool loggedInterfaceDown = false;
uint8_t minMaxReadCounter{0};
int fd{};
diff --git a/src/nvidia-gpu/NvidiaGpuPowerSensor.cpp b/src/nvidia-gpu/NvidiaGpuPowerSensor.cpp
index 756abe6..997ce3d 100644
--- a/src/nvidia-gpu/NvidiaGpuPowerSensor.cpp
+++ b/src/nvidia-gpu/NvidiaGpuPowerSensor.cpp
@@ -32,9 +32,6 @@
using namespace std::literals;
-// GPU Power Sensor Averaging Interval in seconds, 0 implies default
-constexpr uint8_t gpuPowerAveragingIntervalInSec{0};
-
static constexpr double gpuPowerSensorMaxReading = 5000;
static constexpr double gpuPowerSensorMinReading =
std::numeric_limits<uint32_t>::min();
@@ -49,7 +46,7 @@
"power", false, true, gpuPowerSensorMaxReading,
gpuPowerSensorMinReading, conn),
eid(eid), sensorId{sensorId},
- averagingInterval{gpuPowerAveragingIntervalInSec},
+
mctpRequester(mctpRequester), objectServer(objectServer)
{
diff --git a/src/nvidia-gpu/NvidiaGpuPowerSensor.hpp b/src/nvidia-gpu/NvidiaGpuPowerSensor.hpp
index 89b0ab4..7933f75 100644
--- a/src/nvidia-gpu/NvidiaGpuPowerSensor.hpp
+++ b/src/nvidia-gpu/NvidiaGpuPowerSensor.hpp
@@ -45,7 +45,7 @@
uint8_t sensorId;
- uint8_t averagingInterval;
+ uint8_t averagingInterval = 0;
std::shared_ptr<sdbusplus::asio::connection> conn;
diff --git a/src/sensor.hpp b/src/sensor.hpp
index 07d70ec..b21df1e 100644
--- a/src/sensor.hpp
+++ b/src/sensor.hpp
@@ -78,13 +78,18 @@
configInterface(configInterfaceName(objectType)),
isSensorSettable(isSettable), isValueMutable(isMutable), maxValue(max),
minValue(min), thresholds(std::move(thresholdData)),
- hysteresisTrigger((max - min) * 0.01),
- hysteresisPublish((max - min) * 0.0001), dbusConnection(conn),
- readState(readState),
+ dbusConnection(conn), readState(readState),
instrumentation(enableInstrumentation
? std::make_unique<SensorInstrumentation>()
: nullptr)
- {}
+ {
+ // These inits confuse tidy because they're doing constructor params
+ // math on member variables that tidy suggests should be default
+ // initialized. NOLINTBEGIN(cppcoreguidelines-prefer-member-initializer)
+ hysteresisTrigger = (max - min) * 0.01;
+ hysteresisPublish = (max - min) * 0.0001;
+ // NOLINTEND(cppcoreguidelines-prefer-member-initializer)
+ }
virtual ~Sensor() = default;
virtual void checkThresholds() = 0;
std::string name;
@@ -110,8 +115,8 @@
double rawValue = std::numeric_limits<double>::quiet_NaN();
bool overriddenState = false;
bool internalSet = false;
- double hysteresisTrigger;
- double hysteresisPublish;
+ double hysteresisTrigger = 1.0;
+ double hysteresisPublish = 1.0;
std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
PowerState readState;
size_t errCount{0};