summaryrefslogtreecommitdiffstats
path: root/mainloop.cpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-04-17 10:50:36 -0500
committerMatthew Barth <msbarth@us.ibm.com>2018-04-23 13:15:44 -0500
commitb798527cb8c3425f6ad26c68ca67456272e87afa (patch)
tree44169b48212bf552a35ce3765db24eba2ed7c17a /mainloop.cpp
parent09791857fd5322e558ca5238f55ec0f914140b5a (diff)
downloadphosphor-hwmon-b798527cb8c3425f6ad26c68ca67456272e87afa.tar.gz
phosphor-hwmon-b798527cb8c3425f6ad26c68ca67456272e87afa.zip
Check for empty return code list on adding
Move the check for an empty return code list for sensor removal to within the function that adds the return codes per sensor. This eliminates the need to check for an empty return code list prior to calling this function. Tested: Empty return code sensor removal list is handled Change-Id: Icdf3692cd79b3198d90ad8c0688104e4a8040186 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'mainloop.cpp')
-rw-r--r--mainloop.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/mainloop.cpp b/mainloop.cpp
index 1633eef..03c856d 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -78,6 +78,11 @@ std::map<SensorSet::key_type, valueAdjust> sensorAdjusts;
void addRemoveRCs(const SensorSet::key_type& sensor,
const std::string& rcList)
{
+ if (rcList.empty())
+ {
+ return;
+ }
+
// Convert to a char* for strtok
std::vector<char> rmRCs(rcList.c_str(),
rcList.c_str() + rcList.size() + 1);
@@ -138,11 +143,8 @@ auto addValue(const SensorSet::key_type& sensor,
auto& objPath = std::get<std::string>(info);
auto senRmRCs = env::getEnv("REMOVERCS", sensor);
- if (!senRmRCs.empty())
- {
- // Add sensor removal return codes defined per sensor
- addRemoveRCs(sensor, senRmRCs);
- }
+ // Add sensor removal return codes defined per sensor
+ addRemoveRCs(sensor, senRmRCs);
// Retry for up to a second if device is busy
// or has a transient error.
@@ -203,14 +205,6 @@ auto addValue(const SensorSet::key_type& sensor,
*/
void MainLoop::getObject(SensorSet::container_t::const_reference sensor)
{
- // Get list of return codes for removing sensors on device
- std::string deviceRmRCs;
- auto devRmRCs = env::getEnv("REMOVERCS");
- if (!devRmRCs.empty())
- {
- deviceRmRCs.assign(devRmRCs);
- }
-
std::string label;
std::string id;
@@ -251,11 +245,10 @@ void MainLoop::getObject(SensorSet::container_t::const_reference sensor)
return;
}
- if (!deviceRmRCs.empty())
- {
- // Add sensor removal return codes defined at the device level
- addRemoveRCs(sensor.first, deviceRmRCs);
- }
+ // Get list of return codes for removing sensors on device
+ auto devRmRCs = env::getEnv("REMOVERCS");
+ // Add sensor removal return codes defined at the device level
+ addRemoveRCs(sensor.first, devRmRCs);
std::string objectPath{_root};
objectPath.append(1, '/');
OpenPOWER on IntegriCloud