Clang-tidy-14 fixes
Do as the robot commands. All changes made automatically by tidy.
Tested: (Thanks Zhikui)
Downloaded and run on system. Sensors scan normally.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I752f37c9e7a95aa3be8e6980ba6e4b2b48b3395a
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index d9456cd..2a42999 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -53,8 +53,8 @@
"xyz.openbmc_project.Configuration.ADC", false, false,
maxVoltageReading / scaleFactor, minVoltageReading / scaleFactor,
conn, readState),
- std::enable_shared_from_this<ADCSensor>(), objServer(objectServer),
- inputDev(io), waitTimer(io), path(path), scaleFactor(scaleFactor),
+ objServer(objectServer), inputDev(io), waitTimer(io), path(path),
+ scaleFactor(scaleFactor),
sensorPollMs(static_cast<unsigned int>(pollRate * 1000)),
bridgeGpio(std::move(bridgeGpio)), thresholdTimer(io)
{
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index 8e973e7..ef9ef44 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -236,7 +236,7 @@
scaleFactor = std::visit(VariantToFloatVisitor(),
findScaleFactor->second);
// scaleFactor is used in division
- if (scaleFactor == 0.0f)
+ if (scaleFactor == 0.0F)
{
scaleFactor = 1.0;
}
@@ -248,7 +248,7 @@
{
pollRate =
std::visit(VariantToFloatVisitor(), findPollRate->second);
- if (pollRate <= 0.0f)
+ if (pollRate <= 0.0F)
{
pollRate = pollRateDefault; // polling time too short
}
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 87fa53f..f40c96f 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -25,6 +25,7 @@
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
+#include <cstddef>
#include <iostream>
#include <istream>
#include <limits>
@@ -42,8 +43,7 @@
bool show, double dtsOffset) :
Sensor(escapeName(sensorName), std::move(thresholdsIn), sensorConfiguration,
objectType, false, false, 0, 0, conn, PowerState::on),
- std::enable_shared_from_this<CPUSensor>(), objServer(objectServer),
- inputDev(io), waitTimer(io),
+ 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(CPUSensor::sensorPollMs)
@@ -56,7 +56,7 @@
auto& [type, nr, item] = *fileParts;
std::string interfacePath;
const char* units = nullptr;
- if (type.compare("power") == 0)
+ if (type == "power")
{
interfacePath = "/xyz/openbmc_project/sensors/power/" + name;
units = sensor_paths::unitWatts;
@@ -189,7 +189,7 @@
{
for (const auto& vectorItem : mapIt->second)
{
- auto& [suffix, oldValue, dbusName] = vectorItem;
+ const auto& [suffix, oldValue, dbusName] = vectorItem;
auto attrPath = boost::replace_all_copy(path, fileItem, suffix);
if (auto newVal =
readFile(attrPath, CPUSensor::sensorScaleFactor))
@@ -231,7 +231,7 @@
std::cerr << name << " interface down!\n";
loggedInterfaceDown = true;
}
- pollTime = CPUSensor::sensorPollMs * 10u;
+ pollTime = static_cast<size_t>(CPUSensor::sensorPollMs) * 10U;
markFunctional(false);
}
return;
diff --git a/src/CPUSensorMain.cpp b/src/CPUSensorMain.cpp
index 9d5bda4..681fb9f 100644
--- a/src/CPUSensorMain.cpp
+++ b/src/CPUSensorMain.cpp
@@ -107,7 +107,7 @@
const int& cpuId)
{
std::string sensorName = label;
- if (item.compare("input") != 0)
+ if (item != "input")
{
sensorName += " " + item;
}
@@ -116,7 +116,7 @@
bool isWordEnd = true;
std::transform(sensorName.begin(), sensorName.end(), sensorName.begin(),
[&isWordEnd](int c) {
- if (std::isspace(c))
+ if (std::isspace(c) != 0)
{
isWordEnd = true;
}
@@ -396,7 +396,7 @@
}
}
- if (createdSensors.size())
+ if (static_cast<unsigned int>(!createdSensors.empty()) != 0U)
{
std::cout << "Sensor" << (createdSensors.size() == 1 ? " is" : "s are")
<< " created\n";
@@ -478,7 +478,7 @@
msg.addr = config.addr;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
- if (!ioctl(file, PECI_IOC_PING, &msg))
+ if (ioctl(file, PECI_IOC_PING, &msg) == 0)
{
bool dimmReady = false;
for (unsigned int rank = 0; rank < rankNumMax; rank++)
@@ -491,10 +491,10 @@
msg.rx_len = 4;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
- if (!ioctl(file, PECI_IOC_RD_PKG_CFG, &msg))
+ if (ioctl(file, PECI_IOC_RD_PKG_CFG, &msg) == 0)
{
- if (msg.pkg_config[0] || msg.pkg_config[1] ||
- msg.pkg_config[2])
+ if ((msg.pkg_config[0] != 0U) ||
+ (msg.pkg_config[1] != 0U) || (msg.pkg_config[2] != 0U))
{
dimmReady = true;
break;
@@ -554,7 +554,7 @@
}
}
- if (rescanDelaySeconds)
+ if (rescanDelaySeconds != 0U)
{
creationTimer.expires_from_now(
boost::posix_time::seconds(rescanDelaySeconds));
@@ -698,7 +698,7 @@
}
}
- if (cpuConfigs.size())
+ if (static_cast<unsigned int>(!cpuConfigs.empty()) != 0U)
{
std::cout << "CPU config" << (cpuConfigs.size() == 1 ? " is" : "s are")
<< " parsed\n";
diff --git a/src/ChassisIntrusionSensor.cpp b/src/ChassisIntrusionSensor.cpp
index 7b2a0a3..6c40717 100644
--- a/src/ChassisIntrusionSensor.cpp
+++ b/src/ChassisIntrusionSensor.cpp
@@ -106,7 +106,7 @@
return -1;
}
- if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA))
+ if ((funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA) == 0U)
{
std::cerr << "not support I2C_FUNC_SMBUS_READ_BYTE_DATA \n";
close(fd);
@@ -154,7 +154,8 @@
if (!ec)
{
int statusValue = i2cReadFromPch(mBusId, mSlaveAddr);
- std::string newValue = statusValue ? "HardwareIntrusion" : "Normal";
+ std::string newValue =
+ statusValue != 0 ? "HardwareIntrusion" : "Normal";
if (newValue != "unknown" && mValue != newValue)
{
@@ -181,7 +182,7 @@
auto value = mGpioLine.get_value();
// set string defined in chassis redfish schema
- std::string newValue = value ? "HardwareIntrusion" : "Normal";
+ std::string newValue = value != 0 ? "HardwareIntrusion" : "Normal";
if (debug)
{
@@ -236,7 +237,7 @@
// set string defined in chassis redfish schema
auto value = mGpioLine.get_value();
- std::string newValue = value ? "HardwareIntrusion" : "Normal";
+ std::string newValue = value != 0 ? "HardwareIntrusion" : "Normal";
updateValue(newValue);
auto gpioLineFd = mGpioLine.event_get_fd();
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 4d77ef4..67c690f 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -129,7 +129,7 @@
std::cerr << "Error getting pid class\n";
return;
}
- auto classStr = std::get_if<std::string>(&classType);
+ const auto* classStr = std::get_if<std::string>(&classType);
if (classStr == nullptr || *classStr != "fan")
{
return;
@@ -163,8 +163,7 @@
Sensor(escapeName(sensorName), std::move(thresholdData),
sensorConfiguration, "xyz.openbmc_project.Configuration.ExitAirTemp",
false, false, cfmMaxReading, cfmMinReading, conn, PowerState::on),
- std::enable_shared_from_this<CFMSensor>(), parent(parent),
- objServer(objectServer)
+ parent(parent), objServer(objectServer)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/airflow/" + name,
@@ -228,7 +227,7 @@
if (!ec)
{
- auto cfm = std::get_if<double>(&cfmVariant);
+ const auto* cfm = std::get_if<double>(&cfmVariant);
if (cfm != nullptr && *cfm >= minSystemCfm)
{
maxRpm = self->getMaxRpm(*cfm);
@@ -261,7 +260,7 @@
{
return;
}
- const auto reading = std::get_if<double>(&(findValue->second));
+ auto* const reading = std::get_if<double>(&(findValue->second));
if (reading == nullptr)
{
std::cerr << "Got CFM Limit of wrong type\n";
@@ -346,7 +345,7 @@
}
}
-uint64_t CFMSensor::getMaxRpm(uint64_t cfmMaxSetting)
+uint64_t CFMSensor::getMaxRpm(uint64_t cfmMaxSetting) const
{
uint64_t pwmPercent = 100;
double totalCFM = std::numeric_limits<double>::max();
@@ -505,7 +504,7 @@
sensorConfiguration, "xyz.openbmc_project.Configuration.ExitAirTemp",
false, false, exitAirMaxReading, exitAirMinReading, conn,
PowerState::on),
- std::enable_shared_from_this<ExitAirTempSensor>(), objServer(objectServer)
+ objServer(objectServer)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/temperature/" + name,
@@ -600,7 +599,7 @@
{
size_t lastSlash = item.first.rfind("/");
if (lastSlash == std::string::npos ||
- lastSlash == item.first.size() || !item.second.size())
+ lastSlash == item.first.size() || item.second.empty())
{
continue;
}
diff --git a/src/ExternalSensor.cpp b/src/ExternalSensor.cpp
index cc341f8..cc9e7c5 100644
--- a/src/ExternalSensor.cpp
+++ b/src/ExternalSensor.cpp
@@ -28,8 +28,7 @@
double minReading, double timeoutSecs, const PowerState& powerState) :
Sensor(escapeName(sensorName), std::move(thresholdsIn), sensorConfiguration,
objectType, true, true, maxReading, minReading, conn, powerState),
- std::enable_shared_from_this<ExternalSensor>(), objServer(objectServer),
- writeLast(std::chrono::steady_clock::now()),
+ objServer(objectServer), writeLast(std::chrono::steady_clock::now()),
writeTimeout(
std::chrono::duration_cast<std::chrono::steady_clock::duration>(
std::chrono::duration<double>(timeoutSecs))),
diff --git a/src/ExternalSensorMain.cpp b/src/ExternalSensorMain.cpp
index a096175..cbe2388 100644
--- a/src/ExternalSensorMain.cpp
+++ b/src/ExternalSensorMain.cpp
@@ -371,7 +371,7 @@
return;
}
- auto messagePath = message.get_path();
+ const auto* messagePath = message.get_path();
sensorsChanged->insert(messagePath);
if constexpr (debug)
{
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index 0f5e721..ff0ffaa 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -386,7 +386,7 @@
{
bool inverted =
std::get<std::string>(findPolarity->second) == "Low";
- if (auto pinName =
+ if (const auto* pinName =
std::get_if<std::string>(&findPinName->second))
{
presenceSensor = std::make_unique<PresenceSensor>(
@@ -409,8 +409,9 @@
auto findPower = baseConfiguration->second.find("PowerState");
if (findPower != baseConfiguration->second.end())
{
- auto ptrPower = std::get_if<std::string>(&(findPower->second));
- if (ptrPower)
+ const auto* ptrPower =
+ std::get_if<std::string>(&(findPower->second));
+ if (ptrPower != nullptr)
{
setReadState(*ptrPower, powerState);
}
@@ -466,9 +467,9 @@
auto findMutable = connector->second.find("Mutable");
if (findMutable != connector->second.end())
{
- auto ptrMutable =
+ const auto* ptrMutable =
std::get_if<bool>(&(findMutable->second));
- if (ptrMutable)
+ if (ptrMutable != nullptr)
{
isValueMutable = *ptrMutable;
}
@@ -483,7 +484,8 @@
auto findLED = connector->second.find("LED");
if (findLED != connector->second.end())
{
- auto ledName = std::get_if<std::string>(&(findLED->second));
+ const auto* ledName =
+ std::get_if<std::string>(&(findLED->second));
if (ledName == nullptr)
{
std::cerr << "Wrong format for LED of " << sensorName
@@ -504,7 +506,7 @@
led);
if (!pwmPath.empty() && fs::exists(pwmPath) &&
- !pwmSensors.count(pwmPath))
+ (pwmSensors.count(pwmPath) == 0U))
{
pwmSensors[pwmPath] = std::make_unique<PwmSensor>(
pwmName, pwmPath, dbusConnection, objectServer,
diff --git a/src/FileHandle.cpp b/src/FileHandle.cpp
index 6724698..c77fc3d 100644
--- a/src/FileHandle.cpp
+++ b/src/FileHandle.cpp
@@ -19,9 +19,9 @@
FileHandle::FileHandle(int fdIn) : fd(fdIn){};
-FileHandle::FileHandle(FileHandle&& in) noexcept
+FileHandle::FileHandle(FileHandle&& in) noexcept : fd(in.fd)
{
- fd = in.fd;
+
in.fd = -1;
}
@@ -34,7 +34,7 @@
FileHandle::~FileHandle()
{
- if (fd)
+ if (fd != 0)
{
int r = close(fd);
if (r < 0)
@@ -44,7 +44,7 @@
}
}
-int FileHandle::handle()
+int FileHandle::handle() const
{
return fd;
}
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index a9d4748..988e8b9 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -199,8 +199,8 @@
continue;
}
- if ((!std::get_if<uint64_t>(&busCfg->second)) ||
- (!std::get_if<uint64_t>(&addrCfg->second)))
+ if ((std::get_if<uint64_t>(&busCfg->second) == nullptr) ||
+ (std::get_if<uint64_t>(&addrCfg->second) == nullptr))
{
std::cerr << sensor.first.str << " Bus or Address invalid\n";
continue;
@@ -310,7 +310,7 @@
uint64_t bus = 0;
uint64_t addr = 0;
- std::from_chars_result res;
+ std::from_chars_result res{};
res = std::from_chars(busStr.data(), busStr.data() + busStr.size(),
bus);
if (res.ec != std::errc{})
@@ -394,7 +394,7 @@
{
pollRate =
std::visit(VariantToFloatVisitor(), findPollRate->second);
- if (pollRate <= 0.0f)
+ if (pollRate <= 0.0F)
{
pollRate = pollRateDefault; // polling time too short
}
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 22824e0..7eb5e8f 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -51,8 +51,7 @@
std::move(thresholdsIn), sensorConfiguration, objectType, false,
false, thisSensorParameters.maxValue, thisSensorParameters.minValue,
conn, powerState),
- std::enable_shared_from_this<HwmonTempSensor>(), objServer(objectServer),
- inputDev(io), waitTimer(io), path(path),
+ objServer(objectServer), inputDev(io), waitTimer(io), path(path),
offsetValue(thisSensorParameters.offsetValue),
scaleValue(thisSensorParameters.scaleValue),
sensorPollMs(static_cast<unsigned int>(pollRate * 1000))
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index 2f737af..c4c4cd8 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -207,8 +207,9 @@
if (findEthIndex != baseConfiguration->second.end() &&
findName != baseConfiguration->second.end())
{
- auto* pEthIndex = std::get_if<uint64_t>(&findEthIndex->second);
- auto* pName = std::get_if<std::string>(&findName->second);
+ const auto* pEthIndex =
+ std::get_if<uint64_t>(&findEthIndex->second);
+ const auto* pName = std::get_if<std::string>(&findName->second);
if (pEthIndex != nullptr && pName != nullptr)
{
lanInfoMap[*pEthIndex] = *pName;
@@ -221,7 +222,7 @@
}
}
- if (lanInfoMap.size() == 0)
+ if (lanInfoMap.empty())
{
std::cerr << "can't find matched NIC name. \n";
}
@@ -281,8 +282,8 @@
bool oldLanConnected = findLanStatus->second;
// get lan info from map
- std::string lanInfo = "";
- if (lanInfoMap.size() > 0)
+ std::string lanInfo;
+ if (!lanInfoMap.empty())
{
auto findLanInfo = lanInfoMap.find(ethNum);
if (findLanInfo == lanInfoMap.end())
@@ -307,8 +308,8 @@
if (oldLanConnected != newLanConnected)
{
std::string strEthNum = "eth" + std::to_string(ethNum) + lanInfo;
- auto strState = newLanConnected ? "connected" : "lost";
- auto strMsgId =
+ const auto* strState = newLanConnected ? "connected" : "lost";
+ const auto* strMsgId =
newLanConnected ? "OpenBMC.0.1.LanRegained" : "OpenBMC.0.1.LanLost";
lg2::info("{ETHDEV} LAN leash {STATE}", "ETHDEV", strEthNum, "STATE",
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index a8cd25a..8d4dfaa 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -96,7 +96,7 @@
objectServer.remove_interface(association);
}
-std::string IpmbSensor::getSubTypeUnits(void)
+std::string IpmbSensor::getSubTypeUnits(void) const
{
switch (subType)
{
@@ -135,7 +135,7 @@
const IpmbMethodType& response) {
const int& status = std::get<0>(response);
- if (ec || status)
+ if (ec || (status != 0))
{
std::cerr << "Error setting init command for device: " << name
<< "\n";
@@ -270,7 +270,7 @@
{
if (data.size() < 4)
{
- if (!errCount)
+ if (errCount == 0U)
{
std::cerr << "Invalid data length returned for " << name
<< "\n";
@@ -284,7 +284,7 @@
{
if (data.size() < 5)
{
- if (!errCount)
+ if (errCount == 0U)
{
std::cerr << "Invalid data length returned for " << name
<< "\n";
@@ -300,7 +300,7 @@
{
if (data.size() < 5)
{
- if (!errCount)
+ if (errCount == 0U)
{
std::cerr << "Invalid data length returned for " << name
<< "\n";
@@ -315,7 +315,7 @@
{
if (data.size() < 5)
{
- if (!errCount)
+ if (errCount == 0U)
{
std::cerr << "Invalid data length returned for " << name
<< "\n";
@@ -353,7 +353,7 @@
[this](boost::system::error_code ec,
const IpmbMethodType& response) {
const int& status = std::get<0>(response);
- if (ec || status)
+ if (ec || (status != 0))
{
incrementError();
read();
@@ -391,6 +391,7 @@
uint64_t rawData = 0;
for (size_t i = 0; i < end; i++)
{
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
reinterpret_cast<uint8_t*>(&rawData)[i] = data[i];
}
rawValue = static_cast<double>(rawData);
@@ -541,7 +542,7 @@
{
pollRate = std::visit(VariantToFloatVisitor(),
findPollRate->second);
- if (pollRate <= 0.0f)
+ if (pollRate <= 0.0F)
{
pollRate = pollRateDefault;
}
diff --git a/src/MCUTempSensor.cpp b/src/MCUTempSensor.cpp
index c8aef67..68b6df3 100644
--- a/src/MCUTempSensor.cpp
+++ b/src/MCUTempSensor.cpp
@@ -99,7 +99,7 @@
thresholds::checkThresholds(this);
}
-int MCUTempSensor::getMCURegsInfoWord(uint8_t regs, int16_t* pu16data)
+int MCUTempSensor::getMCURegsInfoWord(uint8_t regs, int16_t* pu16data) const
{
std::string i2cBus = "/dev/i2c-" + std::to_string(busId);
@@ -129,7 +129,7 @@
return -1;
}
- if (!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA))
+ if ((funcs & I2C_FUNC_SMBUS_READ_WORD_DATA) == 0U)
{
std::cerr << " not support I2C_FUNC_SMBUS_READ_WORD_DATA\n";
close(fd);
diff --git a/src/NVMeBasicContext.cpp b/src/NVMeBasicContext.cpp
index 760167e..88ddfe8 100644
--- a/src/NVMeBasicContext.cpp
+++ b/src/NVMeBasicContext.cpp
@@ -122,7 +122,7 @@
{
std::cerr << "Failed to read request from in descriptor "
<< strerror(errno) << "\n";
- if (rc)
+ if (rc != 0)
{
return -errno;
}
@@ -158,7 +158,7 @@
std::cerr << "Failed to write block (" << std::dec << len
<< ") length to out descriptor: "
<< strerror(static_cast<int>(-rc)) << "\n";
- if (rc)
+ if (rc != 0)
{
return -errno;
}
@@ -176,7 +176,7 @@
std::cerr << "Failed to write block data of length " << std::dec
<< lenRemaining << " to out pipe: " << strerror(errno)
<< "\n";
- if (rc)
+ if (rc != 0)
{
return -errno;
}
@@ -400,8 +400,8 @@
uint8_t* messageData = static_cast<uint8_t*>(msg);
uint8_t status = messageData[0];
- if ((status & NVME_MI_BASIC_SFLGS_DRIVE_NOT_READY) ||
- !(status & NVME_MI_BASIC_SFLGS_DRIVE_FUNCTIONAL))
+ if (((status & NVME_MI_BASIC_SFLGS_DRIVE_NOT_READY) != 0) ||
+ ((status & NVME_MI_BASIC_SFLGS_DRIVE_FUNCTIONAL) == 0))
{
sensor->markFunctional(false);
return;
diff --git a/src/NVMeSensor.cpp b/src/NVMeSensor.cpp
index fc7bc48..a5257f5 100644
--- a/src/NVMeSensor.cpp
+++ b/src/NVMeSensor.cpp
@@ -22,7 +22,7 @@
static constexpr double minReading = 0;
NVMeSensor::NVMeSensor(sdbusplus::asio::object_server& objectServer,
- boost::asio::io_service&,
+ boost::asio::io_service& /*unused*/,
std::shared_ptr<sdbusplus::asio::connection>& conn,
const std::string& sensorName,
std::vector<thresholds::Threshold>&& thresholdsIn,
diff --git a/src/PSUEvent.cpp b/src/PSUEvent.cpp
index 23f26cc..d1cb40e 100644
--- a/src/PSUEvent.cpp
+++ b/src/PSUEvent.cpp
@@ -146,12 +146,11 @@
std::shared_ptr<std::set<std::string>> asserts,
std::shared_ptr<std::set<std::string>> combineEvent,
std::shared_ptr<bool> state, const std::string& psuName, double pollRate) :
- std::enable_shared_from_this<PSUSubEvent>(),
- eventInterface(std::move(eventInterface)), asserts(std::move(asserts)),
- combineEvent(std::move(combineEvent)), assertState(std::move(state)),
- path(path), eventName(eventName), readState(powerState), waitTimer(io),
- inputDev(io), psuName(psuName), groupEventName(groupEventName),
- systemBus(conn)
+ eventInterface(std::move(eventInterface)),
+ asserts(std::move(asserts)), combineEvent(std::move(combineEvent)),
+ assertState(std::move(state)), path(path), eventName(eventName),
+ readState(powerState), waitTimer(io), inputDev(io), psuName(psuName),
+ groupEventName(groupEventName), systemBus(conn)
{
if (pollRate > 0.0)
{
@@ -308,7 +307,7 @@
return;
}
- if (*assertState == true)
+ if (*assertState)
{
*assertState = false;
auto foundCombine = (*combineEvent).find(groupEventName);
@@ -345,7 +344,7 @@
{
std::cerr << "PSUSubEvent asserted by " << path << "\n";
- if ((*assertState == false) && ((*asserts).empty()))
+ if ((!*assertState) && ((*asserts).empty()))
{
*assertState = true;
if (!assertMessage.empty())
diff --git a/src/PSUSensor.cpp b/src/PSUSensor.cpp
index eedbfcc..bf75e61 100644
--- a/src/PSUSensor.cpp
+++ b/src/PSUSensor.cpp
@@ -47,9 +47,8 @@
const std::string& label, size_t tSize, double pollRate) :
Sensor(escapeName(sensorName), std::move(thresholdsIn), sensorConfiguration,
objectType, false, false, max, min, conn, powerState),
- std::enable_shared_from_this<PSUSensor>(), objServer(objectServer),
- inputDev(io), waitTimer(io), path(path), sensorFactor(factor),
- sensorOffset(offset), thresholdTimer(io)
+ objServer(objectServer), inputDev(io), waitTimer(io), path(path),
+ sensorFactor(factor), sensorOffset(offset), thresholdTimer(io)
{
std::string unitPath = sensor_paths::getPathForUnits(sensorUnits);
if constexpr (debug)
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index 16c601d..c710b4d 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -553,7 +553,7 @@
std::string labelHead;
std::string sensorPathStr = sensorPath.string();
std::string sensorNameStr = sensorPath.filename();
- std::string sensorNameSubStr{""};
+ std::string sensorNameSubStr;
if (std::regex_search(sensorNameStr, matches, sensorNameRegEx))
{
// hwmon *_input filename without number:
@@ -575,7 +575,7 @@
{
std::string sensorPathStrMax = sensorPathStr.substr(pos);
- if (sensorPathStrMax.compare("_max") == 0)
+ if (sensorPathStrMax == "_max")
{
labelPath =
boost::replace_all_copy(sensorPathStr, "max", "label");
@@ -941,8 +941,7 @@
{
std::cerr << "Created total of " << numCreated << " sensors\n";
}
- return;
-}
+ }
void createSensors(
boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer,
diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
index 2ed24a6..ae7b240 100644
--- a/src/PwmSensor.cpp
+++ b/src/PwmSensor.cpp
@@ -50,7 +50,7 @@
pwmMax = sysPwmMax;
}
- if (!pwmValue)
+ if (pwmValue == 0U)
{
// default pwm to non 0
pwmValue = static_cast<uint32_t>(pwmMax * (defaultPwm / 100.0));
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index f5d420d..9afe094 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -192,7 +192,7 @@
{
bool status = thresholds::checkThresholds(this);
- if (redundancy && *redundancy)
+ if ((redundancy != nullptr) && *redundancy)
{
(*redundancy)
->update("/xyz/openbmc_project/sensors/fan_tach/" + name, !status);
@@ -223,7 +223,7 @@
{
gpioLine.request({"FanSensor", gpiod::line_request::EVENT_BOTH_EDGES,
inverted ? gpiod::line_request::FLAG_ACTIVE_LOW : 0});
- status = gpioLine.get_value();
+ status = (gpioLine.get_value() != 0);
int gpioLineFd = gpioLine.event_get_fd();
if (gpioLineFd < 0)
@@ -274,7 +274,7 @@
void PresenceSensor::read(void)
{
gpioLine.event_read();
- status = gpioLine.get_value();
+ status = (gpioLine.get_value() != 0);
// Read is invoked when an edge event is detected by monitorPresence
if (status)
{
@@ -286,7 +286,7 @@
}
}
-bool PresenceSensor::getValue(void)
+bool PresenceSensor::getValue(void) const
{
return status;
}
@@ -332,7 +332,7 @@
newState = redundancy::failed;
break;
}
- if (failedCount)
+ if (failedCount != 0U)
{
newState = redundancy::degraded;
}
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index 1690c25..ff452bc 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -210,7 +210,7 @@
}
std::string property =
- sensor->propertyLevel(threshold.level, threshold.direction);
+ Sensor::propertyLevel(threshold.level, threshold.direction);
if (property.empty())
{
continue;
@@ -446,7 +446,7 @@
return;
}
- std::string property = sensor->propertyAlarm(level, direction);
+ std::string property = Sensor::propertyAlarm(level, direction);
if (property.empty())
{
std::cout << "Alarm property is empty \n";
@@ -505,7 +505,7 @@
{
for (const auto& t : map.at(item))
{
- auto& [suffix, level, direction, offset] = t;
+ const auto& [suffix, level, direction, offset] = t;
auto attrPath =
boost::replace_all_copy(inputPath, item, suffix);
if (auto val = readFile(attrPath, scaleFactor))
diff --git a/src/Utils.cpp b/src/Utils.cpp
index ad43caa..954a5d3 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -337,7 +337,7 @@
const std::variant<std::string>& state) {
if (ec)
{
- if (retries)
+ if (retries != 0U)
{
auto timer = std::make_shared<boost::asio::steady_timer>(
conn->get_io_context());
@@ -370,7 +370,7 @@
const std::variant<std::string>& state) {
if (ec)
{
- if (retries)
+ if (retries != 0U)
{
auto timer = std::make_shared<boost::asio::steady_timer>(
conn->get_io_context());
@@ -386,7 +386,7 @@
std::cerr << "error getting post status " << ec.message() << "\n";
return;
}
- auto& value = std::get<std::string>(state);
+ const auto& value = std::get<std::string>(state);
biosHasPost = (value != "Inactive") &&
(value != "xyz.openbmc_project.State.OperatingSystem."
"Status.OSStatus.Inactive");
@@ -471,7 +471,7 @@
void findLimits(std::pair<double, double>& limits,
const SensorBaseConfiguration* data)
{
- if (!data)
+ if (data == nullptr)
{
return;
}
@@ -648,7 +648,7 @@
<< "\n";
return;
}
- auto manufacturingModeStatus = std::get_if<std::string>(&itr->second);
+ auto* manufacturingModeStatus = std::get_if<std::string>(&itr->second);
handleSpecialModeChange(*manufacturingModeStatus);
});
@@ -670,7 +670,7 @@
{
return;
}
- auto manufacturingModeStatus = std::get_if<std::string>(&itr->second);
+ auto* manufacturingModeStatus = std::get_if<std::string>(&itr->second);
handleSpecialModeChange(*manufacturingModeStatus);
});
@@ -683,7 +683,7 @@
<< "\n";
return;
}
- auto manufacturingModeStatus =
+ const auto* manufacturingModeStatus =
std::get_if<std::string>(&getManufactMode);
handleSpecialModeChange(*manufacturingModeStatus);
},