monitor: Clang format updates
Used `format-code.sh` build script to make changes to conform to clang
format.
Tested: Compiled
Change-Id: Ieead1449cfd4b61333a135740dce03789218f92b
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 33904bd..42b826f 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -13,15 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <experimental/filesystem>
-#include <functional>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog.hpp>
+#include "tach_sensor.hpp"
+
#include "fan.hpp"
#include "sdbusplus.hpp"
-#include "tach_sensor.hpp"
#include "utility.hpp"
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
+
+#include <experimental/filesystem>
+#include <functional>
+
namespace phosphor
{
namespace fan
@@ -34,8 +37,8 @@
constexpr auto FAN_VALUE_PROPERTY = "Value";
using namespace std::experimental::filesystem;
-using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
- Error::InternalFailure;
+using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
/**
* @brief Helper function to read a property
@@ -46,19 +49,15 @@
* @param[in] bus - the dbus object
* @param[out] value - filled in with the property value
*/
-template<typename T>
-static void readProperty(const std::string& interface,
- const std::string& propertyName,
- const std::string& path,
- sdbusplus::bus::bus& bus,
- T& value)
+template <typename T>
+static void
+ readProperty(const std::string& interface, const std::string& propertyName,
+ const std::string& path, sdbusplus::bus::bus& bus, T& value)
{
try
{
- value = util::SDBusPlus::getProperty<T>(bus,
- path,
- interface,
- propertyName);
+ value =
+ util::SDBusPlus::getProperty<T>(bus, path, interface, propertyName);
}
catch (std::exception& e)
{
@@ -66,28 +65,15 @@
}
}
-
-TachSensor::TachSensor(Mode mode,
- sdbusplus::bus::bus& bus,
- Fan& fan,
- const std::string& id,
- bool hasTarget,
- size_t funcDelay,
- const std::string& interface,
- double factor,
- int64_t offset,
- size_t timeout,
+TachSensor::TachSensor(Mode mode, sdbusplus::bus::bus& bus, Fan& fan,
+ const std::string& id, bool hasTarget, size_t funcDelay,
+ const std::string& interface, double factor,
+ int64_t offset, size_t timeout,
const sdeventplus::Event& event) :
_bus(bus),
- _fan(fan),
- _name(FAN_SENSOR_PATH + id),
- _invName(path(fan.getName()) / id),
- _hasTarget(hasTarget),
- _funcDelay(funcDelay),
- _interface(interface),
- _factor(factor),
- _offset(offset),
- _timeout(timeout),
+ _fan(fan), _name(FAN_SENSOR_PATH + id), _invName(path(fan.getName()) / id),
+ _hasTarget(hasTarget), _funcDelay(funcDelay), _interface(interface),
+ _factor(factor), _offset(offset), _timeout(timeout),
_timerMode(TimerMode::func),
_timer(event, std::bind(&Fan::timerExpired, &fan, std::ref(*this)))
{
@@ -102,50 +88,41 @@
// Use getProperty directly to allow a missing sensor object
// to abort construction.
_tachInput = util::SDBusPlus::getProperty<decltype(_tachInput)>(
- _bus,
- _name,
- FAN_SENSOR_VALUE_INTF,
- FAN_VALUE_PROPERTY);
+ _bus, _name, FAN_SENSOR_VALUE_INTF, FAN_VALUE_PROPERTY);
}
catch (std::exception& e)
{
log<level::INFO>("Not monitoring a tach sensor",
- entry("SENSOR=%s", _name.c_str()));
+ entry("SENSOR=%s", _name.c_str()));
throw InvalidSensorError();
}
if (_hasTarget)
{
- readProperty(_interface,
- FAN_TARGET_PROPERTY,
- _name,
- _bus,
+ readProperty(_interface, FAN_TARGET_PROPERTY, _name, _bus,
_tachTarget);
}
auto match = getMatchString(FAN_SENSOR_VALUE_INTF);
tachSignal = std::make_unique<sdbusplus::server::match::match>(
- _bus,
- match.c_str(),
- [this](auto& msg){ this->handleTachChange(msg); });
+ _bus, match.c_str(),
+ [this](auto& msg) { this->handleTachChange(msg); });
if (_hasTarget)
{
match = getMatchString(_interface);
targetSignal = std::make_unique<sdbusplus::server::match::match>(
- _bus,
- match.c_str(),
- [this](auto& msg){ this->handleTargetChange(msg); });
+ _bus, match.c_str(),
+ [this](auto& msg) { this->handleTargetChange(msg); });
}
}
}
std::string TachSensor::getMatchString(const std::string& interface)
{
- return sdbusplus::bus::match::rules::propertiesChanged(
- _name, interface);
+ return sdbusplus::bus::match::rules::propertiesChanged(_name, interface);
}
uint64_t TachSensor::getTarget() const
@@ -174,11 +151,10 @@
* @param[in] propertName - the name of the property
* @param[out] value - the value to store the property value in
*/
-template<typename T>
+template <typename T>
static void readPropertyFromMessage(sdbusplus::message::message& msg,
const std::string& interface,
- const std::string& propertyName,
- T& value)
+ const std::string& propertyName, T& value)
{
std::string sensor;
std::map<std::string, std::variant<T>> data;
@@ -194,28 +170,21 @@
}
}
-
void TachSensor::handleTargetChange(sdbusplus::message::message& msg)
{
- readPropertyFromMessage(msg,
- _interface,
- FAN_TARGET_PROPERTY,
- _tachTarget);
+ readPropertyFromMessage(msg, _interface, FAN_TARGET_PROPERTY, _tachTarget);
- //Check all tach sensors on the fan against the target
+ // Check all tach sensors on the fan against the target
_fan.tachChanged();
}
-
void TachSensor::handleTachChange(sdbusplus::message::message& msg)
{
- readPropertyFromMessage(msg,
- FAN_SENSOR_VALUE_INTF,
- FAN_VALUE_PROPERTY,
- _tachInput);
+ readPropertyFromMessage(msg, FAN_SENSOR_VALUE_INTF, FAN_VALUE_PROPERTY,
+ _tachInput);
- //Check just this sensor against the target
- _fan.tachChanged(*this);
+ // Check just this sensor against the target
+ _fan.tachChanged(*this);
}
void TachSensor::startTimer(TimerMode mode)
@@ -231,40 +200,34 @@
{
using namespace std::chrono;
- switch(mode)
+ switch (mode)
{
- case TimerMode::nonfunc :
- return duration_cast<microseconds>(seconds(_timeout));
- case TimerMode::func :
- return duration_cast<microseconds>(seconds(_funcDelay));
- default :
- // Log an internal error for undefined timer mode
- log<level::ERR>("Undefined timer mode",
- entry("TIMER_MODE=%u", mode));
- elog<InternalFailure>();
- return duration_cast<microseconds>(seconds(0));
+ case TimerMode::nonfunc:
+ return duration_cast<microseconds>(seconds(_timeout));
+ case TimerMode::func:
+ return duration_cast<microseconds>(seconds(_funcDelay));
+ default:
+ // Log an internal error for undefined timer mode
+ log<level::ERR>("Undefined timer mode",
+ entry("TIMER_MODE=%u", mode));
+ elog<InternalFailure>();
+ return duration_cast<microseconds>(seconds(0));
}
}
void TachSensor::updateInventory(bool functional)
{
- auto objectMap = util::getObjMap<bool>(
- _invName,
- util::OPERATIONAL_STATUS_INTF,
- util::FUNCTIONAL_PROPERTY,
- functional);
+ auto objectMap =
+ util::getObjMap<bool>(_invName, util::OPERATIONAL_STATUS_INTF,
+ util::FUNCTIONAL_PROPERTY, functional);
auto response = util::SDBusPlus::lookupAndCallMethod(
- _bus,
- util::INVENTORY_PATH,
- util::INVENTORY_INTF,
- "Notify",
- objectMap);
+ _bus, util::INVENTORY_PATH, util::INVENTORY_INTF, "Notify", objectMap);
if (response.is_method_error())
{
log<level::ERR>("Error in notify update of tach sensor inventory");
}
}
-}
-}
-}
+} // namespace monitor
+} // namespace fan
+} // namespace phosphor