Fix clang-tidy 14 issues
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Idb76ae375eff9a143497942013d94ca3b3252495
diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp
index e667897..c4a47bc 100644
--- a/include/CPUSensor.hpp
+++ b/include/CPUSensor.hpp
@@ -45,7 +45,7 @@
bool show;
size_t pollTime;
bool loggedInterfaceDown = false;
- uint8_t minMaxReadCounter;
+ uint8_t minMaxReadCounter{0};
int fd;
void handleResponse(const boost::system::error_code& err);
void checkThresholds(void) override;
diff --git a/include/ChassisIntrusionSensor.hpp b/include/ChassisIntrusionSensor.hpp
index 142ced3..3f2b7c8 100644
--- a/include/ChassisIntrusionSensor.hpp
+++ b/include/ChassisIntrusionSensor.hpp
@@ -30,19 +30,19 @@
std::shared_ptr<sdbusplus::asio::dbus_interface> mIface;
std::shared_ptr<sdbusplus::asio::connection> mDbusConn;
- IntrusionSensorType mType;
+ IntrusionSensorType mType{IntrusionSensorType::gpio};
// intrusion status. 0: not intruded, 1: intruded
std::string mValue = "unknown";
std::string mOldValue = "unknown";
// valid if it is PCH register via i2c
- int mBusId;
- int mSlaveAddr;
+ int mBusId{-1};
+ int mSlaveAddr{-1};
boost::asio::deadline_timer mPollTimer;
// valid if it is via GPIO
- bool mGpioInverted;
+ bool mGpioInverted{false};
std::string mPinName = "CHASSIS_INTRUSION";
gpiod::line mGpioLine;
boost::asio::posix::stream_descriptor mGpioFd;
diff --git a/include/ExternalSensor.hpp b/include/ExternalSensor.hpp
index 3ca3c8a..30147fd 100644
--- a/include/ExternalSensor.hpp
+++ b/include/ExternalSensor.hpp
@@ -56,7 +56,7 @@
std::chrono::steady_clock::time_point writeLast;
std::chrono::steady_clock::duration writeTimeout;
- bool writeAlive;
+ bool writeAlive{false};
bool writePerishable;
std::function<void(const std::chrono::steady_clock::time_point& now)>
writeHook;
diff --git a/include/NVMeSensor.hpp b/include/NVMeSensor.hpp
index a0dce78..5c70855 100644
--- a/include/NVMeSensor.hpp
+++ b/include/NVMeSensor.hpp
@@ -26,7 +26,7 @@
private:
const unsigned int scanDelayTicks = 5 * 60;
sdbusplus::asio::object_server& objServer;
- unsigned int scanDelay;
+ unsigned int scanDelay{0};
void checkThresholds(void) override;
};
diff --git a/include/PSUEvent.hpp b/include/PSUEvent.hpp
index 3a39164..e7b5c0b 100644
--- a/include/PSUEvent.hpp
+++ b/include/PSUEvent.hpp
@@ -51,7 +51,7 @@
private:
int value = 0;
int fd;
- size_t errCount;
+ size_t errCount{0};
std::string path;
std::string eventName;
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 236c6e7..078fc45 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -68,7 +68,7 @@
minValue(min), thresholds(std::move(thresholdData)),
hysteresisTrigger((max - min) * 0.01),
hysteresisPublish((max - min) * 0.0001), dbusConnection(conn),
- readState(readState), errCount(0),
+ readState(readState),
instrumentation(enableInstrumentation
? std::make_unique<SensorInstrumentation>()
: nullptr)
@@ -102,7 +102,7 @@
double hysteresisPublish;
std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
PowerState readState;
- size_t errCount;
+ size_t errCount{0};
std::unique_ptr<SensorInstrumentation> instrumentation;
// This member variable provides a hook that can be used to receive
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 06d0a69..87fa53f 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -46,8 +46,8 @@
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(CPUSensor::sensorPollMs),
- minMaxReadCounter(0)
+ dtsOffset(dtsOffset), show(show), pollTime(CPUSensor::sensorPollMs)
+
{
if (show)
{
diff --git a/src/ChassisIntrusionSensor.cpp b/src/ChassisIntrusionSensor.cpp
index d480055..7b2a0a3 100644
--- a/src/ChassisIntrusionSensor.cpp
+++ b/src/ChassisIntrusionSensor.cpp
@@ -363,9 +363,7 @@
boost::asio::io_service& io,
std::shared_ptr<sdbusplus::asio::dbus_interface> iface) :
mIface(std::move(iface)),
- mType(IntrusionSensorType::gpio), mValue("unknown"), mOldValue("unknown"),
- mBusId(-1), mSlaveAddr(-1), mPollTimer(io), mGpioInverted(false),
- mGpioFd(io)
+ mValue("unknown"), mOldValue("unknown"), mPollTimer(io), mGpioFd(io)
{}
ChassisIntrusionSensor::~ChassisIntrusionSensor()
diff --git a/src/ExternalSensor.cpp b/src/ExternalSensor.cpp
index 5fba9b4..cc341f8 100644
--- a/src/ExternalSensor.cpp
+++ b/src/ExternalSensor.cpp
@@ -33,7 +33,7 @@
writeTimeout(
std::chrono::duration_cast<std::chrono::steady_clock::duration>(
std::chrono::duration<double>(timeoutSecs))),
- writeAlive(false), writePerishable(timeoutSecs > 0.0)
+ writePerishable(timeoutSecs > 0.0)
{
// The caller must specify what physical characteristic
// an external sensor is expected to be measuring, such as temperature,
diff --git a/src/NVMeSensor.cpp b/src/NVMeSensor.cpp
index 213e320..fc7bc48 100644
--- a/src/NVMeSensor.cpp
+++ b/src/NVMeSensor.cpp
@@ -31,7 +31,7 @@
Sensor(escapeName(sensorName), std::move(thresholdsIn), sensorConfiguration,
NVMeSensor::configType, false, false, maxReading, minReading, conn,
PowerState::on),
- bus(busNumber), objServer(objectServer), scanDelay(0)
+ bus(busNumber), objServer(objectServer)
{
if (bus < 0)
{
diff --git a/src/PSUEvent.cpp b/src/PSUEvent.cpp
index c2ed486..23f26cc 100644
--- a/src/PSUEvent.cpp
+++ b/src/PSUEvent.cpp
@@ -149,9 +149,9 @@
std::enable_shared_from_this<PSUSubEvent>(),
eventInterface(std::move(eventInterface)), asserts(std::move(asserts)),
combineEvent(std::move(combineEvent)), assertState(std::move(state)),
- errCount(0), path(path), eventName(eventName), readState(powerState),
- waitTimer(io), inputDev(io), psuName(psuName),
- groupEventName(groupEventName), systemBus(conn)
+ path(path), eventName(eventName), readState(powerState), waitTimer(io),
+ inputDev(io), psuName(psuName), groupEventName(groupEventName),
+ systemBus(conn)
{
if (pollRate > 0.0)
{
diff --git a/tests/test_Utils.cpp b/tests/test_Utils.cpp
index a66b70c..7b6b947 100644
--- a/tests/test_Utils.cpp
+++ b/tests/test_Utils.cpp
@@ -27,10 +27,12 @@
fs::create_directory(hwmonDir);
auto hwmon10 = hwmonDir / "hwmon10";
fs::create_directory(hwmonDir / "hwmon10");
- std::ofstream{hwmon10 / "temp1_input"};
- std::ofstream{hwmon10 / "temp1_min"};
- std::ofstream{hwmon10 / "temp1_max"};
- std::ofstream{hwmon10 / "temp2_input"};
+ {
+ std::ofstream temp1Input{hwmon10 / "temp1_input"};
+ std::ofstream temp1Min{hwmon10 / "temp1_min"};
+ std::ofstream temp1Max{hwmon10 / "temp1_max"};
+ std::ofstream temp2Input{hwmon10 / "temp2_input"};
+ }
createPECIDir();
}
@@ -50,10 +52,12 @@
auto peci0 =
peciDir / "peci-0/device/0-30/peci-cputemp.0/hwmon/hwmon25";
fs::create_directories(peci0);
- std::ofstream{peci0 / "temp0_input"};
- std::ofstream{peci0 / "temp1_input"};
- std::ofstream{peci0 / "temp2_input"};
- std::ofstream{peci0 / "name"};
+ {
+ std::ofstream temp0Input{peci0 / "temp0_input"};
+ std::ofstream temp1Input{peci0 / "temp1_input"};
+ std::ofstream temp2Input{peci0 / "temp2_input"};
+ std::ofstream name{peci0 / "name"};
+ }
auto devDir = peciDir / "peci-0/peci_dev/peci-0";
fs::create_directories(devDir);
fs::create_directory_symlink("../../../peci-0", devDir / "device");