mainloop: add underscore prefix to members
Most members of mainloop object have an underscore prefix. For
consistency add this prefix to all members. The discussion within
OpenBMC pertaining to prefixes and suffixes for member variables
indicates there is latitude within a repository.
Change-Id: Ifce915923b9b8c58a433f334d45e19143b7b734f
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index b6d44b7..db79134 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -150,7 +150,7 @@
/* Note: The sensor objects all share the same ioAccess object. */
auto sensorObj =
- std::make_unique<sensor::Sensor>(sensor.first, &ioAccess, _devPath);
+ std::make_unique<sensor::Sensor>(sensor.first, &_ioAccess, _devPath);
// Get list of return codes for removing sensors on device
auto devRmRCs = env::getEnv("REMOVERCS");
@@ -165,7 +165,7 @@
ObjectInfo info(&_bus, std::move(objectPath), Object());
RetryIO retryIO(hwmonio::retries, hwmonio::delay);
- if (rmSensors.find(sensor.first) != rmSensors.end())
+ if (_rmSensors.find(sensor.first) != _rmSensors.end())
{
// When adding a sensor that was purposely removed,
// don't retry on errors when reading its value
@@ -181,7 +181,7 @@
catch (const std::system_error& e)
{
auto file =
- sysfs::make_sysfs_path(ioAccess.path(), sensor.first.first,
+ sysfs::make_sysfs_path(_ioAccess.path(), sensor.first.first,
sensor.first.second, hwmon::entry::cinput);
#ifndef REMOVE_ON_FAIL
// Check sensorAdjusts for sensor removal RCs
@@ -189,13 +189,13 @@
if (sAdjusts.rmRCs.count(e.code().value()) > 0)
{
// Return code found in sensor return code removal list
- if (rmSensors.find(sensor.first) == rmSensors.end())
+ if (_rmSensors.find(sensor.first) == _rmSensors.end())
{
// Trace for sensor not already removed from dbus
log<level::INFO>("Sensor not added to dbus for read fail",
entry("FILE=%s", file.c_str()),
entry("RC=%d", e.code().value()));
- rmSensors[std::move(sensor.first)] = std::move(sensor.second);
+ _rmSensors[std::move(sensor.first)] = std::move(sensor.second);
}
return {};
}
@@ -230,19 +230,19 @@
info, scale);
auto target =
- addTarget<hwmon::FanSpeed>(sensor.first, ioAccess, _devPath, info);
+ addTarget<hwmon::FanSpeed>(sensor.first, _ioAccess, _devPath, info);
if (target)
{
target->enable();
}
- addTarget<hwmon::FanPwm>(sensor.first, ioAccess, _devPath, info);
+ addTarget<hwmon::FanPwm>(sensor.first, _ioAccess, _devPath, info);
// All the interfaces have been created. Go ahead
// and emit InterfacesAdded.
valueInterface->emit_object_added();
// Save sensor object specifications
- sensorObjects[sensor.first] = std::move(sensorObj);
+ _sensorObjects[sensor.first] = std::move(sensorObj);
return std::make_pair(std::move(std::get<sensorLabel>(properties)),
std::move(info));
@@ -253,9 +253,9 @@
const char* prefix, const char* root) :
_bus(std::move(bus)),
_manager(_bus, root), _pathParam(param), _hwmonRoot(), _instance(),
- _devPath(devPath), _prefix(prefix), _root(root), state(), ioAccess(path),
- event(sdeventplus::Event::get_default()),
- timer(event, std::bind(&MainLoop::read, this))
+ _devPath(devPath), _prefix(prefix), _root(root), _state(), _ioAccess(path),
+ _event(sdeventplus::Event::get_default()),
+ _timer(_event, std::bind(&MainLoop::read, this))
{
// Strip off any trailing slashes.
std::string p = path;
@@ -279,7 +279,7 @@
void MainLoop::shutdown() noexcept
{
- event.exit(0);
+ _event.exit(0);
}
void MainLoop::run()
@@ -289,15 +289,15 @@
std::function<void()> callback(std::bind(&MainLoop::read, this));
try
{
- timer.restart(std::chrono::microseconds(_interval));
+ _timer.restart(std::chrono::microseconds(_interval));
// TODO: Issue#6 - Optionally look at polling interval sysfs entry.
// TODO: Issue#7 - Should probably periodically check the SensorSet
// for new entries.
- _bus.attach_event(event.get(), SD_EVENT_PRIORITY_IMPORTANT);
- event.loop();
+ _bus.attach_event(_event.get(), SD_EVENT_PRIORITY_IMPORTANT);
+ _event.loop();
}
catch (const std::exception& e)
{
@@ -325,12 +325,12 @@
std::make_tuple(std::move(i.second), std::move((*object).first),
std::move((*object).second));
- state[std::move(i.first)] = std::move(value);
+ _state[std::move(i.first)] = std::move(value);
}
}
/* If there are no sensors specified by labels, exit. */
- if (0 == state.size())
+ if (0 == _state.size())
{
exit(0);
}
@@ -359,7 +359,7 @@
// ensure the objects all exist?
// Iterate through all the sensors.
- for (auto& i : state)
+ for (auto& i : _state)
{
auto& attrs = std::get<0>(i.second);
if (attrs.find(hwmon::entry::input) != attrs.end())
@@ -380,7 +380,7 @@
auto it = obj.find(InterfaceType::STATUS);
if (it != obj.end())
{
- auto fault = ioAccess.read(
+ auto fault = _ioAccess.read(
i.first.first, i.first.second, hwmon::entry::fault,
hwmonio::retries, hwmonio::delay);
auto statusIface =
@@ -395,12 +395,12 @@
// Retry for up to a second if device is busy
// or has a transient error.
std::unique_ptr<sensor::Sensor>& sensor =
- sensorObjects[i.first];
+ _sensorObjects[i.first];
sensor->unlockGpio();
- value = ioAccess.read(i.first.first, i.first.second, input,
- hwmonio::retries, hwmonio::delay);
+ value = _ioAccess.read(i.first.first, i.first.second, input,
+ hwmonio::retries, hwmonio::delay);
sensor->lockGpio();
@@ -435,15 +435,15 @@
catch (const std::system_error& e)
{
auto file = sysfs::make_sysfs_path(
- ioAccess.path(), i.first.first, i.first.second,
+ _ioAccess.path(), i.first.first, i.first.second,
hwmon::entry::cinput);
#ifndef REMOVE_ON_FAIL
// Check sensorAdjusts for sensor removal RCs
- auto& sAdjusts = sensorObjects[i.first]->getAdjusts();
+ auto& sAdjusts = _sensorObjects[i.first]->getAdjusts();
if (sAdjusts.rmRCs.count(e.code().value()) > 0)
{
// Return code found in sensor return code removal list
- if (rmSensors.find(i.first) == rmSensors.end())
+ if (_rmSensors.find(i.first) == _rmSensors.end())
{
// Trace for sensor not already removed from dbus
log<level::INFO>(
@@ -451,7 +451,7 @@
entry("FILE=%s", file.c_str()),
entry("RC=%d", e.code().value()));
// Mark this sensor to be removed from dbus
- rmSensors[i.first] = std::get<0>(i.second);
+ _rmSensors[i.first] = std::get<0>(i.second);
}
continue;
}
@@ -468,7 +468,7 @@
entry("FILE=%s", file.c_str()));
#ifdef REMOVE_ON_FAIL
- rmSensors[i.first] = std::get<0>(i.second);
+ _rmSensors[i.first] = std::get<0>(i.second);
#else
exit(EXIT_FAILURE);
#endif
@@ -477,17 +477,17 @@
}
// Remove any sensors marked for removal
- for (const auto& i : rmSensors)
+ for (const auto& i : _rmSensors)
{
- state.erase(i.first);
+ _state.erase(i.first);
}
#ifndef REMOVE_ON_FAIL
// Attempt to add any sensors that were removed
- auto it = rmSensors.begin();
- while (it != rmSensors.end())
+ auto it = _rmSensors.begin();
+ while (it != _rmSensors.end())
{
- if (state.find(it->first) == state.end())
+ if (_state.find(it->first) == _state.end())
{
SensorSet::container_t::value_type ssValueType =
std::make_pair(it->first, it->second);
@@ -502,15 +502,15 @@
std::move((*object).first),
std::move((*object).second));
- state[std::move(ssValueType.first)] = std::move(value);
+ _state[std::move(ssValueType.first)] = std::move(value);
// Sensor object added, erase entry from removal list
auto file = sysfs::make_sysfs_path(
- ioAccess.path(), it->first.first, it->first.second,
+ _ioAccess.path(), it->first.first, it->first.second,
hwmon::entry::cinput);
log<level::INFO>("Added sensor to dbus after successful read",
entry("FILE=%s", file.c_str()));
- it = rmSensors.erase(it);
+ it = _rmSensors.erase(it);
}
else
{
@@ -520,7 +520,7 @@
else
{
// Sanity check to remove sensors that were re-added
- it = rmSensors.erase(it);
+ it = _rmSensors.erase(it);
}
}
#endif
diff --git a/mainloop.hpp b/mainloop.hpp
index dbf86fb..4f7293d 100644
--- a/mainloop.hpp
+++ b/mainloop.hpp
@@ -94,23 +94,23 @@
/** @brief DBus sensors namespace root. */
const char* _root;
/** @brief DBus object state. */
- SensorState state;
+ SensorState _state;
/** @brief Sleep interval in microseconds. */
uint64_t _interval = default_interval;
/** @brief Hwmon sysfs access. */
- hwmonio::HwmonIO ioAccess;
+ hwmonio::HwmonIO _ioAccess;
/** @brief the Event Loop structure */
- sdeventplus::Event event;
+ sdeventplus::Event _event;
/** @brief Read Timer */
- sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> timer;
+ sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> _timer;
/** @brief Store the specifications of sensor objects */
std::map<SensorSet::key_type, std::unique_ptr<sensor::Sensor>>
- sensorObjects;
+ _sensorObjects;
/**
* @brief Map of removed sensors
*/
- std::map<SensorSet::key_type, SensorSet::mapped_type> rmSensors;
+ std::map<SensorSet::key_type, SensorSet::mapped_type> _rmSensors;
/**
* @brief Get the ID of the sensor