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/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: