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/include/ADCSensor.hpp b/include/ADCSensor.hpp
index 9d2369b..79c220a 100644
--- a/include/ADCSensor.hpp
+++ b/include/ADCSensor.hpp
@@ -70,8 +70,8 @@
std::shared_ptr<sdbusplus::asio::connection>& conn,
boost::asio::io_service& io, const std::string& sensorName,
std::vector<thresholds::Threshold>&& thresholds,
- const double scaleFactor, const float pollRate,
- PowerState readState, const std::string& sensorConfiguration,
+ double scaleFactor, float pollRate, PowerState readState,
+ const std::string& sensorConfiguration,
std::optional<BridgeGpio>&& bridgeGpio);
~ADCSensor() override;
void setupRead(void);
diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp
index c4a47bc..1a98035 100644
--- a/include/CPUSensor.hpp
+++ b/include/CPUSensor.hpp
@@ -46,7 +46,7 @@
size_t pollTime;
bool loggedInterfaceDown = false;
uint8_t minMaxReadCounter{0};
- int fd;
+ int fd{};
void handleResponse(const boost::system::error_code& err);
void checkThresholds(void) override;
void updateMinMaxValues(void);
@@ -100,7 +100,7 @@
{
line.request({"cpusensor", gpiod::line_request::DIRECTION_INPUT,
activeHigh ? 0 : gpiod::line_request::FLAG_ACTIVE_LOW});
- resp = line.get_value();
+ resp = (line.get_value() != 0);
}
catch (const std::system_error&)
{
diff --git a/include/ChassisIntrusionSensor.hpp b/include/ChassisIntrusionSensor.hpp
index 3f2b7c8..56affca 100644
--- a/include/ChassisIntrusionSensor.hpp
+++ b/include/ChassisIntrusionSensor.hpp
@@ -54,7 +54,7 @@
bool mInitialized = false;
void updateValue(const std::string& newValue);
- int i2cReadFromPch(int busId, int slaveAddr);
+ static int i2cReadFromPch(int busId, int slaveAddr);
void pollSensorStatusByPch();
void readGpio();
void pollSensorStatusByGpio();
diff --git a/include/ExitAirTempSensor.hpp b/include/ExitAirTempSensor.hpp
index 2008291..c78253c 100644
--- a/include/ExitAirTempSensor.hpp
+++ b/include/ExitAirTempSensor.hpp
@@ -24,17 +24,17 @@
CFMSensor(std::shared_ptr<sdbusplus::asio::connection>& conn,
const std::string& name, const std::string& sensorConfiguration,
sdbusplus::asio::object_server& objectServer,
- std::vector<thresholds::Threshold>&& thresholds,
+ std::vector<thresholds::Threshold>&& thresholdData,
std::shared_ptr<ExitAirTempSensor>& parent);
~CFMSensor() override;
- bool calculate(double&);
+ bool calculate(double& /*value*/);
void updateReading(void);
void setupMatches(void);
void createMaxCFMIface(void);
void addTachRanges(const std::string& serviceName, const std::string& path);
void checkThresholds(void) override;
- uint64_t getMaxRpm(uint64_t cfmMax);
+ uint64_t getMaxRpm(uint64_t cfmMax) const;
private:
std::vector<sdbusplus::bus::match::match> matches;
@@ -63,7 +63,7 @@
const std::string& name,
const std::string& sensorConfiguration,
sdbusplus::asio::object_server& objectServer,
- std::vector<thresholds::Threshold>&& thresholds);
+ std::vector<thresholds::Threshold>&& thresholdData);
~ExitAirTempSensor() override;
void checkThresholds(void) override;
@@ -79,6 +79,6 @@
sdbusplus::asio::object_server& objServer;
std::chrono::time_point<std::chrono::steady_clock> lastTime;
- double getTotalCFM(void);
+ static double getTotalCFM(void);
bool calculate(double& val);
};
diff --git a/include/ExternalSensor.hpp b/include/ExternalSensor.hpp
index 30147fd..20dd2f0 100644
--- a/include/ExternalSensor.hpp
+++ b/include/ExternalSensor.hpp
@@ -18,7 +18,7 @@
sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& conn,
const std::string& sensorName,
- const std::string& sensorMeasure,
+ const std::string& sensorUnits,
std::vector<thresholds::Threshold>&& thresholdsIn,
const std::string& sensorConfiguration, double maxReading,
double minReading, double timeoutSecs,
diff --git a/include/FileHandle.hpp b/include/FileHandle.hpp
index 46e5539..a2a75d8 100644
--- a/include/FileHandle.hpp
+++ b/include/FileHandle.hpp
@@ -13,8 +13,8 @@
FileHandle() = delete;
FileHandle(const FileHandle&) = delete;
FileHandle& operator=(const FileHandle&) = delete;
- FileHandle(FileHandle&&) noexcept;
- FileHandle& operator=(FileHandle&&) noexcept;
+ FileHandle(FileHandle&& /*in*/) noexcept;
+ FileHandle& operator=(FileHandle&& /*in*/) noexcept;
explicit FileHandle(const std::filesystem::path& name,
std::ios_base::openmode mode = std::ios_base::in |
@@ -23,5 +23,5 @@
explicit FileHandle(int fd);
~FileHandle();
- int handle();
+ int handle() const;
};
\ No newline at end of file
diff --git a/include/HwmonTempSensor.hpp b/include/HwmonTempSensor.hpp
index 8ae92cf..5cf77c3 100644
--- a/include/HwmonTempSensor.hpp
+++ b/include/HwmonTempSensor.hpp
@@ -29,9 +29,8 @@
boost::asio::io_service& io, const std::string& sensorName,
std::vector<thresholds::Threshold>&& thresholds,
const struct SensorParams& thisSensorParameters,
- const float pollRate,
- const std::string& sensorConfiguration,
- const PowerState powerState);
+ float pollRate, const std::string& sensorConfiguration,
+ PowerState powerState);
~HwmonTempSensor() override;
void setupRead(void);
diff --git a/include/IpmbSensor.hpp b/include/IpmbSensor.hpp
index b006652..93c06fb 100644
--- a/include/IpmbSensor.hpp
+++ b/include/IpmbSensor.hpp
@@ -59,7 +59,7 @@
}
// Per IPMI 'Get Sensor Reading' specification
- if (data[1] & (1 << readingUnavailableBit))
+ if ((data[1] & (1 << readingUnavailableBit)) != 0)
{
return false;
}
@@ -81,15 +81,15 @@
boost::asio::io_service& io, const std::string& name,
const std::string& sensorConfiguration,
sdbusplus::asio::object_server& objectServer,
- std::vector<thresholds::Threshold>&& thresholds,
- uint8_t deviceAddress, uint8_t hostSMbusIndex,
- const float pollRate, std::string& sensorTypeName);
+ std::vector<thresholds::Threshold>&& thresholdData,
+ uint8_t deviceAddress, uint8_t hostSMbusIndex, float pollRate,
+ std::string& sensorTypeName);
~IpmbSensor() override;
void checkThresholds(void) override;
void read(void);
void init(void);
- std::string getSubTypeUnits(void);
+ std::string getSubTypeUnits(void) const;
void loadDefaults(void);
void runInitCmd(void);
bool processReading(const std::vector<uint8_t>& data, double& resp);
diff --git a/include/MCUTempSensor.hpp b/include/MCUTempSensor.hpp
index deb7102..e0474f1 100644
--- a/include/MCUTempSensor.hpp
+++ b/include/MCUTempSensor.hpp
@@ -15,7 +15,7 @@
boost::asio::io_service& io, const std::string& name,
const std::string& sensorConfiguration,
sdbusplus::asio::object_server& objectServer,
- std::vector<thresholds::Threshold>&& thresholds,
+ std::vector<thresholds::Threshold>&& thresholdData,
uint8_t busId, uint8_t mcuAddress, uint8_t tempReg);
~MCUTempSensor() override;
@@ -28,7 +28,7 @@
uint8_t tempReg;
private:
- int getMCURegsInfoWord(uint8_t regs, int16_t* pu16data);
+ int getMCURegsInfoWord(uint8_t regs, int16_t* pu16data) const;
sdbusplus::asio::object_server& objectServer;
boost::asio::deadline_timer waitTimer;
};
diff --git a/include/NVMeSensor.hpp b/include/NVMeSensor.hpp
index 5c70855..e58e3c7 100644
--- a/include/NVMeSensor.hpp
+++ b/include/NVMeSensor.hpp
@@ -14,7 +14,7 @@
std::shared_ptr<sdbusplus::asio::connection>& conn,
const std::string& sensorName,
std::vector<thresholds::Threshold>&& thresholds,
- const std::string& sensorConfiguration, const int busNumber);
+ const std::string& sensorConfiguration, int busNumber);
~NVMeSensor() override;
NVMeSensor& operator=(const NVMeSensor& other) = delete;
diff --git a/include/PSUEvent.hpp b/include/PSUEvent.hpp
index e7b5c0b..93c06c1 100644
--- a/include/PSUEvent.hpp
+++ b/include/PSUEvent.hpp
@@ -34,7 +34,7 @@
PSUSubEvent(std::shared_ptr<sdbusplus::asio::dbus_interface> eventInterface,
const std::string& path,
std::shared_ptr<sdbusplus::asio::connection>& conn,
- boost::asio::io_service& io, const PowerState& readState,
+ boost::asio::io_service& io, const PowerState& powerState,
const std::string& groupEventName, const std::string& eventName,
std::shared_ptr<std::set<std::string>> asserts,
std::shared_ptr<std::set<std::string>> combineEvent,
@@ -50,7 +50,7 @@
private:
int value = 0;
- int fd;
+ int fd{};
size_t errCount{0};
std::string path;
std::string eventName;
@@ -77,7 +77,7 @@
{
public:
PSUCombineEvent(
- sdbusplus::asio::object_server& objectSever,
+ sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& conn,
boost::asio::io_service& io, const std::string& psuName,
const PowerState& powerState,
diff --git a/include/PSUSensor.hpp b/include/PSUSensor.hpp
index 523d500..9e32138 100644
--- a/include/PSUSensor.hpp
+++ b/include/PSUSensor.hpp
@@ -38,7 +38,7 @@
void checkThresholds(void) override;
unsigned int sensorPollMs = defaultSensorPollMs;
- int fd;
+ int fd{};
static constexpr size_t warnAfterErrorCount = 10;
public:
diff --git a/include/TachSensor.hpp b/include/TachSensor.hpp
index 75dcd06..c2eaf36 100644
--- a/include/TachSensor.hpp
+++ b/include/TachSensor.hpp
@@ -17,13 +17,13 @@
class PresenceSensor
{
public:
- PresenceSensor(const std::string& pinName, bool inverted,
+ PresenceSensor(const std::string& gpioName, bool inverted,
boost::asio::io_service& io, const std::string& name);
~PresenceSensor();
void monitorPresence(void);
void read(void);
- bool getValue(void);
+ bool getValue(void) const;
private:
bool status = true;
@@ -93,26 +93,26 @@
inline void logFanInserted(const std::string& device)
{
- auto msg = "OpenBMC.0.1.FanInserted";
+ const auto* msg = "OpenBMC.0.1.FanInserted";
lg2::error("Fan Inserted", "REDFISH_MESSAGE_ID", msg,
"REDFISH_MESSAGE_ARGS", device);
}
inline void logFanRemoved(const std::string& device)
{
- auto msg = "OpenBMC.0.1.FanRemoved";
+ const auto* msg = "OpenBMC.0.1.FanRemoved";
lg2::error("Fan Removed", "REDFISH_MESSAGE_ID", msg, "REDFISH_MESSAGE_ARGS",
device);
}
inline void logFanRedundancyLost(void)
{
- auto msg = "OpenBMC.0.1.FanRedundancyLost";
+ const auto* msg = "OpenBMC.0.1.FanRedundancyLost";
lg2::error("Fan Inserted", "REDFISH_MESSAGE_ID", msg);
}
inline void logFanRedundancyRestored(void)
{
- auto msg = "OpenBMC.0.1.FanRedundancyRegained";
+ const auto* msg = "OpenBMC.0.1.FanRedundancyRegained";
lg2::error("Fan Removed", "REDFISH_MESSAGE_ID", msg);
}
diff --git a/include/Thresholds.hpp b/include/Thresholds.hpp
index 94480bb..ae1f528 100644
--- a/include/Thresholds.hpp
+++ b/include/Thresholds.hpp
@@ -67,7 +67,7 @@
struct ThresholdTimer
{
- ThresholdTimer(boost::asio::io_service& ioService) : io(ioService)
+ explicit ThresholdTimer(boost::asio::io_service& ioService) : io(ioService)
{}
bool hasActiveTimer(const Threshold& threshold, bool assert)
@@ -118,10 +118,10 @@
std::vector<thresholds::Threshold>& thresholdVector,
const std::string* matchLabel = nullptr, const int* sensorIndex = nullptr);
-bool parseThresholdsFromAttr(std::vector<thresholds::Threshold>& thresholds,
- const std::string& inputPath,
- const double& scaleFactor,
- const double& offset = 0);
+bool parseThresholdsFromAttr(
+ std::vector<thresholds::Threshold>& thresholdVector,
+ const std::string& inputPath, const double& scaleFactor,
+ const double& offset = 0);
struct ThresholdDefinition
{
@@ -137,9 +137,9 @@
{Level::SOFTSHUTDOWN, 3, "SoftShutdown"},
{Level::HARDSHUTDOWN, 4, "HardShutdown"}}};
-std::string getInterface(const Level level);
+std::string getInterface(Level level);
-void persistThreshold(const std::string& baseInterface, const std::string& path,
+void persistThreshold(const std::string& path, const std::string& baseInterface,
const thresholds::Threshold& threshold,
std::shared_ptr<sdbusplus::asio::connection>& conn,
size_t thresholdCount, const std::string& label);
diff --git a/include/Utils.hpp b/include/Utils.hpp
index 05a36a3..8fc5e80 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -221,7 +221,7 @@
{
std::cerr << "Error getting " << path << ": retries left"
<< retries - 1 << "\n";
- if (!retries)
+ if (retries == 0U)
{
return;
}
@@ -261,7 +261,7 @@
if (ec)
{
std::cerr << "Error calling mapper\n";
- if (!retries)
+ if (retries == 0U)
{
return;
}
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 078fc45..abc6d82 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -132,7 +132,7 @@
return interface;
}
- void updateInstrumentation(double readValue)
+ void updateInstrumentation(double readValue) const
{
// Do nothing if this feature is not enabled
if constexpr (!enableInstrumentation)
@@ -244,7 +244,7 @@
{
oldValue = newValue;
}
- return true;
+ return 1;
}
void setInitialProperties(const std::string& unit,
@@ -379,7 +379,7 @@
}
}
- std::string propertyLevel(const Level lev, const Direction dir)
+ static std::string propertyLevel(const Level lev, const Direction dir)
{
for (const thresholds::ThresholdDefinition& prop :
thresholds::thresProp)
@@ -399,7 +399,7 @@
return "";
}
- std::string propertyAlarm(const Level lev, const Direction dir)
+ static std::string propertyAlarm(const Level lev, const Direction dir)
{
for (const thresholds::ThresholdDefinition& prop :
thresholds::thresProp)
@@ -419,7 +419,7 @@
return "";
}
- bool readingStateGood()
+ bool readingStateGood() const
{
if (readState == PowerState::on && !isPowerOn())
{
@@ -480,7 +480,7 @@
}
}
- bool inError()
+ bool inError() const
{
return errCount >= errorThreshold;
}
@@ -518,7 +518,8 @@
void updateProperty(
std::shared_ptr<sdbusplus::asio::dbus_interface>& interface,
- double& oldValue, const double& newValue, const char* dbusPropertyName)
+ double& oldValue, const double& newValue,
+ const char* dbusPropertyName) const
{
if (requiresUpdate(oldValue, newValue))
{
@@ -532,18 +533,14 @@
}
}
- bool requiresUpdate(const double& lVal, const double& rVal)
+ bool requiresUpdate(const double& lVal, const double& rVal) const
{
if (std::isnan(lVal) || std::isnan(rVal))
{
return true;
}
double diff = std::abs(lVal - rVal);
- if (diff > hysteresisPublish)
- {
- return true;
- }
- return false;
+ return diff > hysteresisPublish;
}
private: