Fix thresholds not found
Due to the same attribute name "thresholds" in class 'ADCSensor' and
'Sensor', the function hasWarningInterface use this parameter from class
ADCSensor and cause it can not found the correct thresholds.
Rename the "thresholds" to "thresholdsIn" to avoid this problem.
Tested: Add thresholds to adc, cpu, hwmon and fan sensor and verify pass.
Signed-off-by: Jeff Lin <JeffLin2@quantatw.com>
Change-Id: I6a8a5f7036dd9f195a7848ff03fa5f51966c2d2d
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index 646c269..3cd40e8 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -48,12 +48,13 @@
sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& conn,
boost::asio::io_service& io, const std::string& sensorName,
- std::vector<thresholds::Threshold>&& thresholds,
+ std::vector<thresholds::Threshold>&& thresholdsIn,
const double scaleFactor, PowerState readState,
const std::string& sensorConfiguration,
std::optional<BridgeGpio>&& bridgeGpio) :
- Sensor(boost::replace_all_copy(sensorName, " ", "_"), std::move(thresholds),
- sensorConfiguration, "xyz.openbmc_project.Configuration.ADC",
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"),
+ std::move(thresholdsIn), sensorConfiguration,
+ "xyz.openbmc_project.Configuration.ADC",
maxVoltageReading / scaleFactor, minVoltageReading / scaleFactor,
conn, readState),
std::enable_shared_from_this<ADCSensor>(), objServer(objectServer),
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index c28b230..939bbc2 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -37,11 +37,12 @@
sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& conn,
boost::asio::io_service& io, const std::string& sensorName,
- std::vector<thresholds::Threshold>&& thresholds,
+ std::vector<thresholds::Threshold>&& thresholdsIn,
const std::string& sensorConfiguration, int cpuId,
bool show, double dtsOffset) :
- Sensor(boost::replace_all_copy(sensorName, " ", "_"), std::move(thresholds),
- sensorConfiguration, objectType, 0, 0, conn, PowerState::on),
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"),
+ std::move(thresholdsIn), sensorConfiguration, objectType, 0, 0, conn,
+ PowerState::on),
objServer(objectServer), inputDev(io), waitTimer(io), path(path),
privTcontrol(std::numeric_limits<double>::quiet_NaN()),
dtsOffset(dtsOffset), show(show), pollTime(CPUSensor::sensorPollMs),
diff --git a/src/ExternalSensor.cpp b/src/ExternalSensor.cpp
index c19ec40..c6db174 100644
--- a/src/ExternalSensor.cpp
+++ b/src/ExternalSensor.cpp
@@ -21,16 +21,16 @@
const std::string& objectType, sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& conn,
const std::string& sensorName, const std::string& sensorUnits,
- std::vector<thresholds::Threshold>&& thresholds,
+ std::vector<thresholds::Threshold>&& thresholdsIn,
const std::string& sensorConfiguration, const double& maxReading,
const double& minReading, const PowerState& powerState) :
// TODO(): When the Mutable feature is integrated,
// make sure all ExternalSensor instances are mutable,
// because that is the entire point of ExternalSensor,
// to accept sensor values written by an external source.
- Sensor(boost::replace_all_copy(sensorName, " ", "_"), std::move(thresholds),
- sensorConfiguration, objectType, maxReading, minReading, conn,
- powerState),
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"),
+ std::move(thresholdsIn), sensorConfiguration, objectType, maxReading,
+ minReading, conn, powerState),
std::enable_shared_from_this<ExternalSensor>(), objServer(objectServer)
{
// The caller must specify what physical characteristic
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index b804b25..41fc357 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -42,11 +42,11 @@
sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& conn,
boost::asio::io_service& io, const std::string& sensorName,
- std::vector<thresholds::Threshold>&& thresholds, const float pollRate,
+ std::vector<thresholds::Threshold>&& thresholdsIn, const float pollRate,
const std::string& sensorConfiguration, const PowerState powerState) :
- Sensor(boost::replace_all_copy(sensorName, " ", "_"), std::move(thresholds),
- sensorConfiguration, objectType, maxReading, minReading, conn,
- powerState),
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"),
+ std::move(thresholdsIn), sensorConfiguration, objectType, maxReading,
+ minReading, conn, powerState),
std::enable_shared_from_this<HwmonTempSensor>(), objServer(objectServer),
inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), path(path),
sensorPollMs(static_cast<unsigned int>(pollRate * 1000))
diff --git a/src/NVMeSensor.cpp b/src/NVMeSensor.cpp
index db6a05b..1c78354 100644
--- a/src/NVMeSensor.cpp
+++ b/src/NVMeSensor.cpp
@@ -433,12 +433,13 @@
boost::asio::io_service&,
std::shared_ptr<sdbusplus::asio::connection>& conn,
const std::string& sensorName,
- std::vector<thresholds::Threshold>&& thresholds,
+ std::vector<thresholds::Threshold>&& thresholdsIn,
const std::string& sensorConfiguration,
const int busNumber) :
- Sensor(boost::replace_all_copy(sensorName, " ", "_"), std::move(thresholds),
- sensorConfiguration, "xyz.openbmc_project.Configuration.NVMe",
- maxReading, minReading, conn, PowerState::on),
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"),
+ std::move(thresholdsIn), sensorConfiguration,
+ "xyz.openbmc_project.Configuration.NVMe", maxReading, minReading,
+ conn, PowerState::on),
objServer(objectServer), bus(busNumber)
{
sensorInterface = objectServer.add_interface(
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index bffc30e..1ec979f 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -46,12 +46,12 @@
std::unique_ptr<PresenceSensor>&& presenceSensor,
std::optional<RedundancySensor>* redundancy,
boost::asio::io_service& io, const std::string& fanName,
- std::vector<thresholds::Threshold>&& thresholds,
+ std::vector<thresholds::Threshold>&& thresholdsIn,
const std::string& sensorConfiguration,
const std::pair<size_t, size_t>& limits,
const PowerState& powerState,
const std::optional<std::string>& ledIn) :
- Sensor(boost::replace_all_copy(fanName, " ", "_"), std::move(thresholds),
+ Sensor(boost::replace_all_copy(fanName, " ", "_"), std::move(thresholdsIn),
sensorConfiguration, objectType, limits.second, limits.first, conn,
powerState),
objServer(objectServer), redundancy(redundancy),