fix warnings
Fix a couple warnings so we can use meson warning level 3. Instances of
the following warnings are found and resolved:
Wreorder
Wsign-compare
Change-Id: Ia223b42aa6bf743cfa0e7042cc3d5a18977459be
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/include/ADCSensor.hpp b/include/ADCSensor.hpp
index 39b9aaa..dfd8713 100644
--- a/include/ADCSensor.hpp
+++ b/include/ADCSensor.hpp
@@ -69,7 +69,7 @@
boost::asio::deadline_timer waitTimer;
boost::asio::streambuf readBuf;
std::string path;
- int errCount;
+ size_t errCount;
double scaleFactor;
std::optional<BridgeGpio> bridgeGpio;
PowerState readState;
diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp
index 589b1f6..8f9cb6e 100644
--- a/include/CPUSensor.hpp
+++ b/include/CPUSensor.hpp
@@ -43,7 +43,7 @@
double privTcontrol;
double dtsOffset;
bool show;
- int errCount;
+ size_t errCount;
void setupRead(void);
void handleResponse(const boost::system::error_code& err);
void checkThresholds(void) override;
diff --git a/include/HwmonTempSensor.hpp b/include/HwmonTempSensor.hpp
index d5c1051..677cab8 100644
--- a/include/HwmonTempSensor.hpp
+++ b/include/HwmonTempSensor.hpp
@@ -24,7 +24,7 @@
boost::asio::deadline_timer waitTimer;
boost::asio::streambuf readBuf;
std::string path;
- int errCount;
+ size_t errCount;
void setupRead(void);
void handleResponse(const boost::system::error_code& err);
void checkThresholds(void) override;
diff --git a/include/PSUEvent.hpp b/include/PSUEvent.hpp
index e47670b..89840a3 100644
--- a/include/PSUEvent.hpp
+++ b/include/PSUEvent.hpp
@@ -41,7 +41,7 @@
private:
int value = 0;
- int errCount;
+ size_t errCount;
std::string path;
std::string eventName;
boost::asio::deadline_timer waitTimer;
diff --git a/include/PSUSensor.hpp b/include/PSUSensor.hpp
index c0ebe6a..4ab553f 100644
--- a/include/PSUSensor.hpp
+++ b/include/PSUSensor.hpp
@@ -27,7 +27,7 @@
boost::asio::deadline_timer waitTimer;
boost::asio::streambuf readBuf;
std::string path;
- int errCount;
+ size_t errCount;
unsigned int sensorFactor;
void setupRead(void);
void handleResponse(const boost::system::error_code& err);
diff --git a/include/TachSensor.hpp b/include/TachSensor.hpp
index 567355b..c7c1b0e 100644
--- a/include/TachSensor.hpp
+++ b/include/TachSensor.hpp
@@ -83,7 +83,7 @@
boost::asio::deadline_timer waitTimer;
boost::asio::streambuf readBuf;
std::string path;
- int errCount;
+ size_t errCount;
void setupRead(void);
void handleResponse(const boost::system::error_code& err);
void checkThresholds(void) override;
diff --git a/include/sensor.hpp b/include/sensor.hpp
index f83a45e..263cbfb 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -19,7 +19,7 @@
const double max, const double min) :
name(name),
configurationPath(configurationPath), objectType(objectType),
- thresholds(std::move(thresholdData)), maxValue(max), minValue(min),
+ maxValue(max), minValue(min), thresholds(std::move(thresholdData)),
hysteresis((max - min) * 0.01)
{
}
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index 3daadcb..22194e8 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -54,10 +54,10 @@
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration,
"xyz.openbmc_project.Configuration.ADC", maxReading, minReading),
- objServer(objectServer), scaleFactor(scaleFactor), path(path),
- readState(std::move(readState)), inputDev(io, open(path.c_str(), O_RDONLY)),
- waitTimer(io), errCount(0), thresholdTimer(io, this),
- bridgeGpio(std::move(bridgeGpio))
+ objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
+ waitTimer(io), path(path), errCount(0), scaleFactor(scaleFactor),
+ bridgeGpio(std::move(bridgeGpio)), readState(std::move(readState)),
+ thresholdTimer(io, this)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/voltage/" + name,
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 9458896..27c9c38 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -44,8 +44,9 @@
std::move(_thresholds), sensorConfiguration, objectType, maxReading,
minReading),
objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
- path(path), waitTimer(io), show(show), dtsOffset(dtsOffset),
- privTcontrol(std::numeric_limits<double>::quiet_NaN()), errCount(0)
+ waitTimer(io), path(path),
+ privTcontrol(std::numeric_limits<double>::quiet_NaN()),
+ dtsOffset(dtsOffset), show(show), errCount(0)
{
nameTcontrol = labelTcontrol;
nameTcontrol += " CPU" + std::to_string(cpuId);
diff --git a/src/ChassisIntrusionSensor.cpp b/src/ChassisIntrusionSensor.cpp
index 536589c..60d0f0d 100644
--- a/src/ChassisIntrusionSensor.cpp
+++ b/src/ChassisIntrusionSensor.cpp
@@ -339,10 +339,10 @@
ChassisIntrusionSensor::ChassisIntrusionSensor(
boost::asio::io_service& io,
std::shared_ptr<sdbusplus::asio::dbus_interface> iface) :
- mPollTimer(io),
- mIface(iface), mInputDev(io), mType(IntrusionSensorType::gpio), mBusId(-1),
- mSlaveAddr(-1), mGpioIndex(-1), mGpioInverted(false), mValue("unknown"),
- mOldValue("unknown")
+ mIface(iface),
+ mType(IntrusionSensorType::gpio), mValue("unknown"), mOldValue("unknown"),
+ mBusId(-1), mSlaveAddr(-1), mPollTimer(io), mGpioIndex(-1),
+ mGpioInverted(false), mInputDev(io)
{
}
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 9692f7f..adf670e 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -166,8 +166,8 @@
std::move(thresholdData), sensorConfiguration,
"xyz.openbmc_project.Configuration.ExitAirTemp", cfmMaxReading,
cfmMinReading),
- std::enable_shared_from_this<CFMSensor>(), dbusConnection(conn),
- parent(parent), objServer(objectServer)
+ std::enable_shared_from_this<CFMSensor>(), parent(parent),
+ dbusConnection(conn), objServer(objectServer)
{
sensorInterface =
objectServer.add_interface("/xyz/openbmc_project/sensors/cfm/" + name,
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index b195c0c..15d4d38 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -47,8 +47,8 @@
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration, objectType, maxReading,
minReading),
- path(path), objServer(objectServer),
- inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0)
+ objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
+ waitTimer(io), path(path), errCount(0)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/temperature/" + name,
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index a7ca495..96da5f6 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -275,7 +275,7 @@
*pState == "degraded");
// get ethNum from path. /org/freedesktop/network1/link/_32 for eth0
- int pos = pathName.find("/_");
+ size_t pos = pathName.find("/_");
if (pos == std::string::npos || pathName.length() <= pos + 2)
{
std::cerr << "unexpected path name " << pathName << "\n";
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index d9a4e25..b0b20de 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -69,8 +69,8 @@
std::move(thresholdData), sensorConfiguration,
"xyz.openbmc_project.Configuration.ExitAirTemp", ipmbMaxReading,
ipmbMinReading),
- objectServer(objectServer), dbusConnection(conn), waitTimer(io),
- deviceAddress(deviceAddress), readState(PowerState::on)
+ deviceAddress(deviceAddress), readState(PowerState::on),
+ objectServer(objectServer), dbusConnection(conn), waitTimer(io)
{
std::string dbusPath = sensorPathPrefix + sensorTypeName + "/" + name;
diff --git a/src/MCUTempSensor.cpp b/src/MCUTempSensor.cpp
index 581919c..06376b6 100644
--- a/src/MCUTempSensor.cpp
+++ b/src/MCUTempSensor.cpp
@@ -62,8 +62,8 @@
std::move(thresholdData), sensorConfiguration,
"xyz.openbmc_project.Configuration.ExitAirTemp", mcuTempMaxReading,
mcuTempMinReading),
- objectServer(objectServer), dbusConnection(conn), waitTimer(io),
- busId(busId), mcuAddress(mcuAddress), tempReg(tempReg)
+ busId(busId), mcuAddress(mcuAddress), tempReg(tempReg),
+ objectServer(objectServer), dbusConnection(conn), waitTimer(io)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/temperature/" + name,
diff --git a/src/PSUEvent.cpp b/src/PSUEvent.cpp
index f56b281..08101de 100644
--- a/src/PSUEvent.cpp
+++ b/src/PSUEvent.cpp
@@ -98,9 +98,9 @@
std::shared_ptr<std::set<std::string>> combineEvent,
std::shared_ptr<bool> state, const std::string& psuName) :
eventInterface(eventInterface),
- inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0),
- path(path), eventName(eventName), assertState(state), asserts(asserts),
- combineEvent(combineEvent), psuName(psuName)
+ asserts(asserts), combineEvent(combineEvent), assertState(state),
+ errCount(0), path(path), eventName(eventName), waitTimer(io),
+ inputDev(io, open(path.c_str(), O_RDONLY)), psuName(psuName)
{
auto found = logID.find(eventName);
if (found == logID.end())
diff --git a/src/PSUSensor.cpp b/src/PSUSensor.cpp
index a7b72a8..fc24704 100644
--- a/src/PSUSensor.cpp
+++ b/src/PSUSensor.cpp
@@ -44,8 +44,9 @@
double max, double min) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration, objectType, max, min),
- path(path), objServer(objectServer),
- inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0),
+ objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
+ waitTimer(io), path(path), errCount(0),
+
sensorFactor(factor)
{
if constexpr (DEBUG)
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index eed0168..3d386e4 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -544,7 +544,7 @@
{
/* Find out sensor name index for this label */
std::regex rgx("[A-Za-z]+([0-9]+)");
- int nameIndex{0};
+ size_t nameIndex{0};
if (std::regex_search(labelHead, matches, rgx))
{
nameIndex = std::stoi(matches[1]);
diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
index 3fdde65..5aa729e 100644
--- a/src/PwmSensor.cpp
+++ b/src/PwmSensor.cpp
@@ -29,8 +29,8 @@
PwmSensor::PwmSensor(const std::string& name, const std::string& sysPath,
sdbusplus::asio::object_server& objectServer,
const std::string& sensorConfiguration) :
- name(name),
- sysPath(sysPath), objectServer(objectServer)
+ sysPath(sysPath),
+ objectServer(objectServer), name(name)
{
// add interface under sensor and Control.FanPwm as Control is used
// in obmc project, also add sensor so it can be viewed as a sensor
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index 86b548f..91a08c1 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -50,9 +50,10 @@
const std::pair<size_t, size_t>& limits) :
Sensor(boost::replace_all_copy(fanName, " ", "_"), std::move(_thresholds),
sensorConfiguration, objectType, limits.second, limits.first),
- path(path), objServer(objectServer), presence(std::move(presenceSensor)),
- redundancy(redundancy), inputDev(io, open(path.c_str(), O_RDONLY)),
- waitTimer(io), errCount(0)
+ objServer(objectServer), redundancy(redundancy),
+ presence(std::move(presenceSensor)),
+ inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), path(path),
+ errCount(0)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/fan_tach/" + name,
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index bbddcde..fe5537f 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -120,7 +120,7 @@
std::shared_ptr<sdbusplus::asio::connection>& conn,
size_t thresholdCount)
{
- for (int ii = 0; ii < thresholdCount; ii++)
+ for (size_t ii = 0; ii < thresholdCount; ii++)
{
std::string thresholdInterface =
baseInterface + ".Thresholds" + std::to_string(ii);