clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.
See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.
Change-Id: Ica590f8613f1fb89ab1ca676ac51c1cc7e38d67f
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
IndentWrappedFunctionNames: true
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
@@ -98,13 +98,14 @@
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
diff --git a/control/actions.cpp b/control/actions.cpp
index 25db5a9..1a40ce8 100644
--- a/control/actions.cpp
+++ b/control/actions.cpp
@@ -73,9 +73,10 @@
// Set/update the services of the group
zone.setServices(&group);
auto services = zone.getGroupServices(&group);
- auto missingOwner = std::any_of(
- services.begin(), services.end(),
- [](const auto& s) { return !std::get<hasOwnerPos>(s); });
+ auto missingOwner =
+ std::any_of(services.begin(), services.end(), [](const auto& s) {
+ return !std::get<hasOwnerPos>(s);
+ });
if (missingOwner)
{
zone.setSpeed(speed);
@@ -88,20 +89,20 @@
void set_request_speed_base_with_max(control::Zone& zone, const Group& group)
{
int64_t base = 0;
- std::for_each(group.begin(), group.end(),
- [&zone, &base](const auto& entry) {
- try
- {
- auto value = zone.template getPropertyValue<int64_t>(
- std::get<pathPos>(entry), std::get<intfPos>(entry),
- std::get<propPos>(entry));
- base = std::max(base, value);
- }
- catch (const std::out_of_range& oore)
- {
- // Property value not found, base request speed unchanged
- }
- });
+ std::for_each(
+ group.begin(), group.end(), [&zone, &base](const auto& entry) {
+ try
+ {
+ auto value = zone.template getPropertyValue<int64_t>(
+ std::get<pathPos>(entry), std::get<intfPos>(entry),
+ std::get<propPos>(entry));
+ base = std::max(base, value);
+ }
+ catch (const std::out_of_range& oore)
+ {
+ // Property value not found, base request speed unchanged
+ }
+ });
// A request speed base of 0 defaults to the current target speed
zone.setRequestSpeedBase(base);
}
diff --git a/control/actions.hpp b/control/actions.hpp
index fd7c8a6..fd9ad62 100644
--- a/control/actions.hpp
+++ b/control/actions.hpp
@@ -85,8 +85,8 @@
template <typename T>
auto count_state_before_speed(size_t count, T&& state, uint64_t speed)
{
- return [count, speed, state = std::forward<T>(state)](auto& zone,
- auto& group) {
+ return [count, speed,
+ state = std::forward<T>(state)](auto& zone, auto& group) {
size_t numAtState = 0;
for (auto& entry : group)
{
@@ -135,30 +135,30 @@
if (group.size() != 0)
{
auto count = 0;
- auto sumValue =
- std::accumulate(group.begin(), group.end(), 0,
- [&zone, &count](T sum, auto const& entry) {
- try
- {
- return sum + zone.template getPropertyValue<T>(
- std::get<pathPos>(entry),
- std::get<intfPos>(entry),
- std::get<propPos>(entry));
- }
- catch (const std::out_of_range& oore)
- {
- count++;
- return sum;
- }
- });
+ auto sumValue = std::accumulate(
+ group.begin(), group.end(), 0,
+ [&zone, &count](T sum, const auto& entry) {
+ try
+ {
+ return sum + zone.template getPropertyValue<T>(
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry));
+ }
+ catch (const std::out_of_range& oore)
+ {
+ count++;
+ return sum;
+ }
+ });
if ((group.size() - count) > 0)
{
auto groupSize = static_cast<int64_t>(group.size());
auto avgValue = sumValue / (groupSize - count);
auto it = std::find_if(val_to_speed.begin(), val_to_speed.end(),
- [&avgValue](auto const& entry) {
- return avgValue < entry.first;
- });
+ [&avgValue](const auto& entry) {
+ return avgValue < entry.first;
+ });
if (it != std::end(val_to_speed))
{
speed = (*it).second;
@@ -187,28 +187,28 @@
Action
set_ceiling_from_average_sensor_value(std::map<T, uint64_t>&& val_to_speed)
{
- return [val_to_speed = std::move(val_to_speed)](Zone& zone,
- const Group& group) {
+ return [val_to_speed =
+ std::move(val_to_speed)](Zone& zone, const Group& group) {
auto speed = zone.getCeiling();
if (group.size() != 0)
{
auto count = 0;
- auto sumValue =
- std::accumulate(group.begin(), group.end(), 0,
- [&zone, &count](T sum, auto const& entry) {
- try
- {
- return sum + zone.template getPropertyValue<T>(
- std::get<pathPos>(entry),
- std::get<intfPos>(entry),
- std::get<propPos>(entry));
- }
- catch (const std::out_of_range& oore)
- {
- count++;
- return sum;
- }
- });
+ auto sumValue = std::accumulate(
+ group.begin(), group.end(), 0,
+ [&zone, &count](T sum, const auto& entry) {
+ try
+ {
+ return sum + zone.template getPropertyValue<T>(
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry));
+ }
+ catch (const std::out_of_range& oore)
+ {
+ count++;
+ return sum;
+ }
+ });
if ((group.size() - count) > 0)
{
auto groupSize = static_cast<int64_t>(group.size());
@@ -307,33 +307,34 @@
return [speedDelta, factor = std::forward<T>(factor),
state = std::forward<T>(state)](auto& zone, auto& group) {
auto netDelta = zone.getIncSpeedDelta();
- std::for_each(group.begin(), group.end(),
- [&zone, &state, &factor, &speedDelta,
- &netDelta](auto const& entry) {
- try
- {
- T value = zone.template getPropertyValue<T>(
- std::get<pathPos>(entry), std::get<intfPos>(entry),
- std::get<propPos>(entry));
- // TODO openbmc/phosphor-fan-presence#7 - Support possible
- // state types for comparison
- if (value >= state)
+ std::for_each(
+ group.begin(), group.end(),
+ [&zone, &state, &factor, &speedDelta,
+ &netDelta](const auto& entry) {
+ try
{
- // Increase by at least a single delta(factor)
- // to attempt bringing under 'state'
- auto delta = std::max((value - state), factor);
- // Increase is the factor applied to the
- // difference times the given speed delta
- netDelta = std::max(
- netDelta,
- static_cast<uint64_t>((delta / factor) * speedDelta));
+ T value = zone.template getPropertyValue<T>(
+ std::get<pathPos>(entry), std::get<intfPos>(entry),
+ std::get<propPos>(entry));
+ // TODO openbmc/phosphor-fan-presence#7 - Support possible
+ // state types for comparison
+ if (value >= state)
+ {
+ // Increase by at least a single delta(factor)
+ // to attempt bringing under 'state'
+ auto delta = std::max((value - state), factor);
+ // Increase is the factor applied to the
+ // difference times the given speed delta
+ netDelta = std::max(netDelta,
+ static_cast<uint64_t>(
+ (delta / factor) * speedDelta));
+ }
}
- }
- catch (const std::out_of_range& oore)
- {
- // Property value not found, netDelta unchanged
- }
- });
+ catch (const std::out_of_range& oore)
+ {
+ // Property value not found, netDelta unchanged
+ }
+ });
// Request speed change for target speed update
zone.requestSpeedIncrease(netDelta);
};
@@ -380,8 +381,8 @@
// difference times the given speed delta
netDelta = std::min(
netDelta,
- static_cast<uint64_t>(((state - value) / factor) *
- speedDelta));
+ static_cast<uint64_t>(
+ ((state - value) / factor) * speedDelta));
}
}
else
@@ -426,20 +427,21 @@
return [state = std::forward<T>(state), defEvents = std::move(defEvents),
altEvents = std::move(altEvents)](auto& zone, auto& group) {
// Compare all group entries to the state
- auto useAlt = std::all_of(group.begin(), group.end(),
- [&zone, &state](auto const& entry) {
- try
- {
- return zone.template getPropertyValue<T>(
- std::get<pathPos>(entry), std::get<intfPos>(entry),
- std::get<propPos>(entry)) == state;
- }
- catch (const std::out_of_range& oore)
- {
- // Default to property not equal when not found
- return false;
- }
- });
+ auto useAlt = std::all_of(
+ group.begin(), group.end(), [&zone, &state](const auto& entry) {
+ try
+ {
+ return zone.template getPropertyValue<T>(
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry)) == state;
+ }
+ catch (const std::out_of_range& oore)
+ {
+ // Default to property not equal when not found
+ return false;
+ }
+ });
const std::vector<SetSpeedEvent>* rmEvents = &altEvents;
const std::vector<SetSpeedEvent>* initEvents = &defEvents;
@@ -452,10 +454,10 @@
// Remove events
std::for_each(rmEvents->begin(), rmEvents->end(),
- [&zone](auto const& entry) { zone.removeEvent(entry); });
+ [&zone](const auto& entry) { zone.removeEvent(entry); });
// Init events
std::for_each(initEvents->begin(), initEvents->end(),
- [&zone](auto const& entry) { zone.initEvent(entry); });
+ [&zone](const auto& entry) { zone.initEvent(entry); });
};
}
@@ -488,7 +490,7 @@
if (group.size() != 0)
{
std::vector<T> validValues;
- for (auto const& member : group)
+ for (const auto& member : group)
{
try
{
@@ -525,9 +527,9 @@
// Use determined median sensor value to find floor speed
auto it = std::find_if(valueToSpeed.begin(), valueToSpeed.end(),
- [&median](auto const& entry) {
- return median < entry.first;
- });
+ [&median](const auto& entry) {
+ return median < entry.first;
+ });
if (it != std::end(valueToSpeed))
{
speed = (*it).second;
@@ -554,20 +556,21 @@
auto update_default_floor(T&& state, uint64_t speed)
{
return [speed, state = std::forward<T>(state)](auto& zone, auto& group) {
- auto updateDefFloor = std::all_of(group.begin(), group.end(),
- [&zone, &state](auto const& entry) {
- try
- {
- return zone.template getPropertyValue<T>(
- std::get<pathPos>(entry), std::get<intfPos>(entry),
- std::get<propPos>(entry)) == state;
- }
- catch (const std::out_of_range& oore)
- {
- // Default to property not equal when not found
- return false;
- }
- });
+ auto updateDefFloor = std::all_of(
+ group.begin(), group.end(), [&zone, &state](const auto& entry) {
+ try
+ {
+ return zone.template getPropertyValue<T>(
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry)) == state;
+ }
+ catch (const std::out_of_range& oore)
+ {
+ // Default to property not equal when not found
+ return false;
+ }
+ });
if (!updateDefFloor)
{
@@ -599,34 +602,37 @@
return [state = std::forward<T>(state),
events = std::move(events)](auto& zone, auto& group) {
// Compare all group entries to the state
- auto useEvents = std::all_of(group.begin(), group.end(),
- [&zone, &state](auto const& entry) {
- try
- {
- return zone.template getPropertyValue<T>(
- std::get<pathPos>(entry), std::get<intfPos>(entry),
- std::get<propPos>(entry)) == state;
- }
- catch (const std::out_of_range& oore)
- {
- // Default to property not equal when not found
- return false;
- }
- });
+ auto useEvents = std::all_of(
+ group.begin(), group.end(), [&zone, &state](const auto& entry) {
+ try
+ {
+ return zone.template getPropertyValue<T>(
+ std::get<pathPos>(entry),
+ std::get<intfPos>(entry),
+ std::get<propPos>(entry)) == state;
+ }
+ catch (const std::out_of_range& oore)
+ {
+ // Default to property not equal when not found
+ return false;
+ }
+ });
if (useEvents)
{
// Init events
- std::for_each(
- events.begin(), events.end(),
- [&zone](auto const& entry) { zone.initEvent(entry); });
+ std::for_each(events.begin(), events.end(),
+ [&zone](const auto& entry) {
+ zone.initEvent(entry);
+ });
}
else
{
// Remove events
- std::for_each(
- events.begin(), events.end(),
- [&zone](auto const& entry) { zone.removeEvent(entry); });
+ std::for_each(events.begin(), events.end(),
+ [&zone](const auto& entry) {
+ zone.removeEvent(entry);
+ });
}
};
}
diff --git a/control/fanctl.cpp b/control/fanctl.cpp
index d244a86..9789c24 100644
--- a/control/fanctl.cpp
+++ b/control/fanctl.cpp
@@ -80,10 +80,9 @@
* @return map of paths by fan name
*/
-std::map<std::string, std::vector<std::string>>
- getPathsFromIface(const std::string& path, const std::string& iface,
- const std::vector<std::string>& fans,
- bool shortPath = false)
+std::map<std::string, std::vector<std::string>> getPathsFromIface(
+ const std::string& path, const std::string& iface,
+ const std::vector<std::string>& fans, bool shortPath = false)
{
std::map<std::string, std::vector<std::string>> dest;
@@ -162,8 +161,8 @@
}
// load tach sensor paths for each fan
- pathMap["tach"] = getPathsFromIface(paths["tach"],
- interfaces["SensorValue"], fanNames);
+ pathMap["tach"] =
+ getPathsFromIface(paths["tach"], interfaces["SensorValue"], fanNames);
// load inventory Item data for each fan
pathMap["inventory"] = getPathsFromIface(
@@ -221,18 +220,18 @@
std::string path("/xyz/openbmc_project/state/bmc0");
std::string iface("xyz.openbmc_project.State.BMC");
- ret[3] = SDBusPlus::getProperty<std::string>(path, iface,
- "CurrentBMCState");
+ ret[3] =
+ SDBusPlus::getProperty<std::string>(path, iface, "CurrentBMCState");
path = "/xyz/openbmc_project/state/chassis0";
iface = "xyz.openbmc_project.State.Chassis";
- ret[4] = SDBusPlus::getProperty<std::string>(path, iface,
- "CurrentPowerState");
+ ret[4] =
+ SDBusPlus::getProperty<std::string>(path, iface, "CurrentPowerState");
path = "/xyz/openbmc_project/state/host0";
iface = "xyz.openbmc_project.State.Host";
- ret[5] = SDBusPlus::getProperty<std::string>(path, iface,
- "CurrentHostState");
+ ret[5] =
+ SDBusPlus::getProperty<std::string>(path, iface, "CurrentHostState");
return ret;
}
@@ -725,8 +724,8 @@
#ifdef CONTROL_USE_JSON
// Query dump
- auto cmdDumpQuery = commands->add_subcommand("query_dump",
- "Query the dump file");
+ auto cmdDumpQuery =
+ commands->add_subcommand("query_dump", "Query the dump file");
cmdDumpQuery->set_help_flag("-h, --help", "Query the dump file");
cmdDumpQuery
diff --git a/control/functor.hpp b/control/functor.hpp
index 14d27d2..fd6fe6a 100644
--- a/control/functor.hpp
+++ b/control/functor.hpp
@@ -93,8 +93,8 @@
{}
Properties(const char* path, const char* intf, const char* prop,
U&& handler) :
- _path(path),
- _intf(intf), _prop(prop), _handler(std::forward<U>(handler))
+ _path(path), _intf(intf), _prop(prop),
+ _handler(std::forward<U>(handler))
{}
/** @brief Run signal handler function
@@ -125,8 +125,8 @@
}
// Retrieve the property's value applying any visitors necessary
- auto value = zone.getPropertyValueVisitor<T>(_intf, _prop,
- it->second);
+ auto value =
+ zone.getPropertyValueVisitor<T>(_intf, _prop, it->second);
_handler(zone, _path, _intf, _prop, std::forward<T>(value));
}
@@ -160,23 +160,23 @@
std::for_each(
group.begin(), group.end(),
[&zone, handler = std::move(_handler)](const auto& member) {
- auto path = std::get<pathPos>(member);
- auto intf = std::get<intfPos>(member);
- auto prop = std::get<propPos>(member);
- try
- {
- auto val = zone.getPropertyByName<T>(path, intf, prop);
- handler(zone, path, intf, prop, std::forward<T>(val));
- }
- catch (const sdbusplus::exception_t&)
- {
- // Property value not sent to handler
- }
- catch (const util::DBusError&)
- {
- // Property value not sent to handler
- }
- });
+ auto path = std::get<pathPos>(member);
+ auto intf = std::get<intfPos>(member);
+ auto prop = std::get<propPos>(member);
+ try
+ {
+ auto val = zone.getPropertyByName<T>(path, intf, prop);
+ handler(zone, path, intf, prop, std::forward<T>(val));
+ }
+ catch (const sdbusplus::exception_t&)
+ {
+ // Property value not sent to handler
+ }
+ catch (const util::DBusError&)
+ {
+ // Property value not sent to handler
+ }
+ });
}
private:
@@ -236,8 +236,8 @@
InterfacesAdded& operator=(InterfacesAdded&&) = default;
InterfacesAdded(const char* path, const char* intf, const char* prop,
U&& handler) :
- _path(path),
- _intf(intf), _prop(prop), _handler(std::forward<U>(handler))
+ _path(path), _intf(intf), _prop(prop),
+ _handler(std::forward<U>(handler))
{}
/** @brief Run signal handler function
@@ -276,8 +276,8 @@
}
// Retrieve the property's value applying any visitors necessary
- auto value = zone.getPropertyValueVisitor<T>(_intf, _prop,
- itProp->second);
+ auto value =
+ zone.getPropertyValueVisitor<T>(_intf, _prop, itProp->second);
_handler(zone, _path, _intf, _prop, std::forward<T>(value));
}
@@ -430,32 +430,33 @@
{
std::string name = "";
bool hasOwner = false;
- std::for_each(group.begin(), group.end(),
- [&zone, &group, &name, &hasOwner,
- handler = std::move(_handler)](const auto& member) {
- auto path = std::get<pathPos>(member);
- auto intf = std::get<intfPos>(member);
- try
- {
- auto servName = zone.getService(path, intf);
- if (name != servName)
+ std::for_each(
+ group.begin(), group.end(),
+ [&zone, &group, &name, &hasOwner,
+ handler = std::move(_handler)](const auto& member) {
+ auto path = std::get<pathPos>(member);
+ auto intf = std::get<intfPos>(member);
+ try
{
- name = servName;
- hasOwner = util::SDBusPlus::callMethodAndRead<bool>(
- zone.getBus(), "org.freedesktop.DBus",
- "/org/freedesktop/DBus", "org.freedesktop.DBus",
- "NameHasOwner", name);
- // Update service name owner state list of a group
- handler(zone, name, hasOwner);
+ auto servName = zone.getService(path, intf);
+ if (name != servName)
+ {
+ name = servName;
+ hasOwner = util::SDBusPlus::callMethodAndRead<bool>(
+ zone.getBus(), "org.freedesktop.DBus",
+ "/org/freedesktop/DBus", "org.freedesktop.DBus",
+ "NameHasOwner", name);
+ // Update service name owner state list of a group
+ handler(zone, name, hasOwner);
+ }
}
- }
- catch (const util::DBusMethodError& e)
- {
- // Failed to get service name owner state
- name = "";
- hasOwner = false;
- }
- });
+ catch (const util::DBusMethodError& e)
+ {
+ // Failed to get service name owner state
+ name = "";
+ hasOwner = false;
+ }
+ });
}
private:
diff --git a/control/json/actions/action.hpp b/control/json/actions/action.hpp
index 0377a8a..93cd9e2 100644
--- a/control/json/actions/action.hpp
+++ b/control/json/actions/action.hpp
@@ -153,10 +153,11 @@
*/
virtual void addZone(Zone& zone)
{
- auto itZone = std::find_if(_zones.begin(), _zones.end(),
- [&zone](std::reference_wrapper<Zone>& z) {
- return z.get().getName() == zone.getName();
- });
+ auto itZone =
+ std::find_if(_zones.begin(), _zones.end(),
+ [&zone](std::reference_wrapper<Zone>& z) {
+ return z.get().getName() == zone.getName();
+ });
if (itZone == _zones.end())
{
_zones.emplace_back(std::reference_wrapper<Zone>(zone));
@@ -223,8 +224,8 @@
json groups = json::array();
std::for_each(_groups.begin(), _groups.end(),
[&groups](const auto& group) {
- groups.push_back(group.getName());
- });
+ groups.push_back(group.getName());
+ });
json output;
output["groups"] = groups;
return output;
@@ -331,11 +332,11 @@
else
{
// Construct list of available actions
- auto acts = std::accumulate(std::next(actions.begin()),
- actions.end(), actions.begin()->first,
- [](auto list, auto act) {
- return std::move(list) + ", " + act.first;
- });
+ auto acts = std::accumulate(
+ std::next(actions.begin()), actions.end(),
+ actions.begin()->first, [](auto list, auto act) {
+ return std::move(list) + ", " + act.first;
+ });
log<level::ERR>(
std::format("Action '{}' is not registered", name).c_str(),
entry("AVAILABLE_ACTIONS=%s", acts.c_str()));
diff --git a/control/json/actions/count_state_floor.cpp b/control/json/actions/count_state_floor.cpp
index 25cb3e6..a285a90 100644
--- a/control/json/actions/count_state_floor.cpp
+++ b/control/json/actions/count_state_floor.cpp
@@ -71,10 +71,10 @@
if (!_timer)
{
- _timer = std::make_unique<Timer>(util::SDEventPlus::getEvent(),
- [&zone, this](Timer&) {
- zone.setFloorHold(getUniqueName(), _floor, doCount());
- });
+ _timer = std::make_unique<Timer>(
+ util::SDEventPlus::getEvent(), [&zone, this](Timer&) {
+ zone.setFloorHold(getUniqueName(), _floor, doCount());
+ });
}
if (!_timer->isEnabled())
diff --git a/control/json/actions/default_floor.cpp b/control/json/actions/default_floor.cpp
index 95a2219..5ca3c10 100644
--- a/control/json/actions/default_floor.cpp
+++ b/control/json/actions/default_floor.cpp
@@ -43,8 +43,8 @@
auto isMissingOwner =
std::any_of(members.begin(), members.end(),
[&intf = group.getInterface()](const auto& member) {
- return !Manager::hasOwner(member, intf);
- });
+ return !Manager::hasOwner(member, intf);
+ });
if (isMissingOwner)
{
zone.setFloor(zone.getDefaultFloor());
diff --git a/control/json/actions/get_managed_objects.cpp b/control/json/actions/get_managed_objects.cpp
index 099a68b..eb5600e 100644
--- a/control/json/actions/get_managed_objects.cpp
+++ b/control/json/actions/get_managed_objects.cpp
@@ -60,11 +60,11 @@
}
// Look for the ObjectManager as an ancestor of the path.
- auto hasObjMgr = std::any_of(objMgrPaths.begin(),
- objMgrPaths.end(),
- [member](const auto& path) {
- return member.find(path) != std::string::npos;
- });
+ auto hasObjMgr = std::any_of(
+ objMgrPaths.begin(), objMgrPaths.end(),
+ [member](const auto& path) {
+ return member.find(path) != std::string::npos;
+ });
if (!hasObjMgr || services.find(service) == services.end())
{
@@ -99,8 +99,8 @@
// Add zone to _actions
std::for_each(_actions.begin(), _actions.end(),
[&zone](std::unique_ptr<ActionBase>& action) {
- action->addZone(zone);
- });
+ action->addZone(zone);
+ });
}
}
diff --git a/control/json/actions/mapped_floor.cpp b/control/json/actions/mapped_floor.cpp
index 3de2188..ab50075 100644
--- a/control/json/actions/mapped_floor.cpp
+++ b/control/json/actions/mapped_floor.cpp
@@ -232,12 +232,13 @@
{
std::visit(
[&value](auto&& val) {
- using V = std::decay_t<decltype(val)>;
- if constexpr (std::is_same_v<int32_t, V> || std::is_same_v<int64_t, V>)
- {
- value = static_cast<double>(val);
- }
- },
+ using V = std::decay_t<decltype(val)>;
+ if constexpr (std::is_same_v<int32_t, V> ||
+ std::is_same_v<int64_t, V>)
+ {
+ value = static_cast<double>(val);
+ }
+ },
value);
}
@@ -261,17 +262,17 @@
{
std::visit(
[&group, this](auto&& val) {
- using V = std::decay_t<decltype(val)>;
- if constexpr (!std::is_same_v<double, V> &&
- !std::is_same_v<int32_t, V> &&
- !std::is_same_v<int64_t, V>)
- {
- throw std::runtime_error{std::format(
- "{}: Group {} has more than one member but "
- "isn't numeric",
- ActionBase::getName(), group.getName())};
- }
- },
+ using V = std::decay_t<decltype(val)>;
+ if constexpr (!std::is_same_v<double, V> &&
+ !std::is_same_v<int32_t, V> &&
+ !std::is_same_v<int64_t, V>)
+ {
+ throw std::runtime_error{std::format(
+ "{}: Group {} has more than one member but "
+ "isn't numeric",
+ ActionBase::getName(), group.getName())};
+ }
+ },
value);
checked = true;
}
diff --git a/control/json/actions/missing_owner_target.cpp b/control/json/actions/missing_owner_target.cpp
index deed3cb..40894be 100644
--- a/control/json/actions/missing_owner_target.cpp
+++ b/control/json/actions/missing_owner_target.cpp
@@ -46,8 +46,8 @@
auto isMissingOwner =
std::any_of(members.begin(), members.end(),
[&intf = group.getInterface()](const auto& member) {
- return !Manager::hasOwner(member, intf);
- });
+ return !Manager::hasOwner(member, intf);
+ });
// Update zone's target hold based on action results
zone.setTargetHold(group.getName(), _target, isMissingOwner);
}
diff --git a/control/json/actions/net_target_increase.cpp b/control/json/actions/net_target_increase.cpp
index 7341a35..9c712a7 100644
--- a/control/json/actions/net_target_increase.cpp
+++ b/control/json/actions/net_target_increase.cpp
@@ -57,77 +57,80 @@
for (const auto& group : _groups)
{
const auto& members = group.getMembers();
- std::for_each(members.begin(), members.end(),
- [this, &zone, &group, &netDelta](const auto& member) {
- try
- {
- auto value = Manager::getObjValueVariant(
- member, group.getInterface(), group.getProperty());
- if (std::holds_alternative<int64_t>(value) ||
- std::holds_alternative<double>(value))
+ std::for_each(
+ members.begin(), members.end(),
+ [this, &zone, &group, &netDelta](const auto& member) {
+ try
{
- // Where a group of int/doubles are greater than or
- // equal to the state(some value) provided, request an
- // increase of the configured delta times the difference
- // between the group member's value and configured state
- // value.
- if (value >= _state)
+ auto value = Manager::getObjValueVariant(
+ member, group.getInterface(), group.getProperty());
+ if (std::holds_alternative<int64_t>(value) ||
+ std::holds_alternative<double>(value))
{
- uint64_t incDelta = 0;
- if (auto dblPtr = std::get_if<double>(&value))
+ // Where a group of int/doubles are greater than or
+ // equal to the state(some value) provided, request an
+ // increase of the configured delta times the difference
+ // between the group member's value and configured state
+ // value.
+ if (value >= _state)
{
- incDelta = static_cast<uint64_t>(
- (*dblPtr - std::get<double>(_state)) * _delta);
+ uint64_t incDelta = 0;
+ if (auto dblPtr = std::get_if<double>(&value))
+ {
+ incDelta = static_cast<uint64_t>(
+ (*dblPtr - std::get<double>(_state)) *
+ _delta);
+ }
+ else
+ {
+ // Increase by at least a single delta
+ // to attempt bringing under provided 'state'
+ auto deltaFactor =
+ std::max((std::get<int64_t>(value) -
+ std::get<int64_t>(_state)),
+ int64_t(1));
+ incDelta =
+ static_cast<uint64_t>(deltaFactor * _delta);
+ }
+ netDelta = std::max(netDelta, incDelta);
}
- else
+ }
+ else if (std::holds_alternative<bool>(value))
+ {
+ // Where a group of booleans equal the state(`true` or
+ // `false`) provided, request an increase of the
+ // configured delta
+ if (_state == value)
{
- // Increase by at least a single delta
- // to attempt bringing under provided 'state'
- auto deltaFactor =
- std::max((std::get<int64_t>(value) -
- std::get<int64_t>(_state)),
- int64_t(1));
- incDelta =
- static_cast<uint64_t>(deltaFactor * _delta);
+ netDelta = std::max(netDelta, _delta);
}
- netDelta = std::max(netDelta, incDelta);
}
- }
- else if (std::holds_alternative<bool>(value))
- {
- // Where a group of booleans equal the state(`true` or
- // `false`) provided, request an increase of the
- // configured delta
- if (_state == value)
+ else if (std::holds_alternative<std::string>(value))
{
- netDelta = std::max(netDelta, _delta);
+ // Where a group of strings equal the state(some string)
+ // provided, request an increase of the configured delta
+ if (_state == value)
+ {
+ netDelta = std::max(netDelta, _delta);
+ }
}
- }
- else if (std::holds_alternative<std::string>(value))
- {
- // Where a group of strings equal the state(some string)
- // provided, request an increase of the configured delta
- if (_state == value)
+ else
{
- netDelta = std::max(netDelta, _delta);
+ // Unsupported group member type for this action
+ log<level::ERR>(
+ std::format(
+ "Action {}: Unsupported group member type "
+ "given. [object = {} : {} : {}]",
+ ActionBase::getName(), member,
+ group.getInterface(), group.getProperty())
+ .c_str());
}
}
- else
+ catch (const std::out_of_range& oore)
{
- // Unsupported group member type for this action
- log<level::ERR>(
- std::format("Action {}: Unsupported group member type "
- "given. [object = {} : {} : {}]",
- ActionBase::getName(), member,
- group.getInterface(), group.getProperty())
- .c_str());
+ // Property value not found, netDelta unchanged
}
- }
- catch (const std::out_of_range& oore)
- {
- // Property value not found, netDelta unchanged
- }
- });
+ });
}
// Request increase to target
zone.requestIncrease(netDelta);
diff --git a/control/json/actions/override_fan_target.cpp b/control/json/actions/override_fan_target.cpp
index 103008a..33fbd34 100644
--- a/control/json/actions/override_fan_target.cpp
+++ b/control/json/actions/override_fan_target.cpp
@@ -87,8 +87,8 @@
{
fanList = std::accumulate(std::next(_fans.begin()), _fans.end(),
_fans[0], [](auto list, auto fan) {
- return std::move(list) + ", " + fan;
- });
+ return std::move(list) + ", " + fan;
+ });
}
record(std::format("Adding fan target lock of {} on fans [{}] zone {}",
diff --git a/control/json/actions/pcie_card_floors.cpp b/control/json/actions/pcie_card_floors.cpp
index 106d42f..a5cfee5 100644
--- a/control/json/actions/pcie_card_floors.cpp
+++ b/control/json/actions/pcie_card_floors.cpp
@@ -221,8 +221,8 @@
auto deviceID = getPCIeDeviceProperty(card, deviceIDProp);
auto vendorID = getPCIeDeviceProperty(card, vendorIDProp);
auto subsystemID = getPCIeDeviceProperty(card, subsystemIDProp);
- auto subsystemVendorID = getPCIeDeviceProperty(card,
- subsystemVendorIDProp);
+ auto subsystemVendorID =
+ getPCIeDeviceProperty(card, subsystemVendorIDProp);
return _cardMetadata->lookup(deviceID, vendorID, subsystemID,
subsystemVendorID);
@@ -251,10 +251,10 @@
// Find the card that plugs in this slot based on if the
// slot is part of the path, like slotA/cardA
- auto it = std::find_if(_pcieDevices.begin(), _pcieDevices.end(),
- [slotPath](const auto& path) {
- return path.find(slotPath + '/') != std::string::npos;
- });
+ auto it = std::find_if(
+ _pcieDevices.begin(), _pcieDevices.end(), [slotPath](const auto& path) {
+ return path.find(slotPath + '/') != std::string::npos;
+ });
if (it == _pcieDevices.end())
{
diff --git a/control/json/actions/set_parameter_from_group_max.cpp b/control/json/actions/set_parameter_from_group_max.cpp
index 99e184f..811f37c 100644
--- a/control/json/actions/set_parameter_from_group_max.cpp
+++ b/control/json/actions/set_parameter_from_group_max.cpp
@@ -64,20 +64,20 @@
bool invalid = false;
std::visit(
[&group, &invalid, this](auto&& val) {
- using V = std::decay_t<decltype(val)>;
- if constexpr (!std::is_same_v<double, V> &&
- !std::is_same_v<int32_t, V> &&
- !std::is_same_v<int64_t, V>)
- {
- log<level::ERR>(std::format("{}: Group {} has more "
- "than one member but "
- "isn't numeric",
- ActionBase::getName(),
- group.getName())
- .c_str());
- invalid = true;
- }
- },
+ using V = std::decay_t<decltype(val)>;
+ if constexpr (!std::is_same_v<double, V> &&
+ !std::is_same_v<int32_t, V> &&
+ !std::is_same_v<int64_t, V>)
+ {
+ log<level::ERR>(std::format("{}: Group {} has more "
+ "than one member but "
+ "isn't numeric",
+ ActionBase::getName(),
+ group.getName())
+ .c_str());
+ invalid = true;
+ }
+ },
value);
if (invalid)
{
diff --git a/control/json/actions/target_from_group_max.cpp b/control/json/actions/target_from_group_max.cpp
index 45216bb..d92457d 100644
--- a/control/json/actions/target_from_group_max.cpp
+++ b/control/json/actions/target_from_group_max.cpp
@@ -185,19 +185,19 @@
// considered numeric here.
std::visit(
[&group, &invalid, this](auto&& val) {
- using V = std::decay_t<decltype(val)>;
- if constexpr (!std::is_same_v<double, V> &&
- !std::is_same_v<int32_t, V> &&
- !std::is_same_v<int64_t, V>)
- {
- log<level::ERR>(std::format("{}: Group {}'s member "
- "isn't numeric",
- ActionBase::getName(),
- group.getName())
- .c_str());
- invalid = true;
- }
- },
+ using V = std::decay_t<decltype(val)>;
+ if constexpr (!std::is_same_v<double, V> &&
+ !std::is_same_v<int32_t, V> &&
+ !std::is_same_v<int64_t, V>)
+ {
+ log<level::ERR>(
+ std::format("{}: Group {}'s member "
+ "isn't numeric",
+ ActionBase::getName(), group.getName())
+ .c_str());
+ invalid = true;
+ }
+ },
value);
if (invalid)
{
diff --git a/control/json/actions/timer_based_actions.cpp b/control/json/actions/timer_based_actions.cpp
index 02779bd..21dbc29 100644
--- a/control/json/actions/timer_based_actions.cpp
+++ b/control/json/actions/timer_based_actions.cpp
@@ -42,9 +42,10 @@
{
// If any of groups' value == nullopt(i.e. not configured), action is
// driven by the service owned state of the group members
- _byOwner = std::any_of(
- _groups.begin(), _groups.end(),
- [](const auto& group) { return group.getValue() == std::nullopt; });
+ _byOwner =
+ std::any_of(_groups.begin(), _groups.end(), [](const auto& group) {
+ return group.getValue() == std::nullopt;
+ });
setTimerConf(jsonObj);
setActions(jsonObj);
@@ -57,12 +58,13 @@
// If any service providing a group member is not owned, start
// timer and if all members' services are owned, stop timer.
if (std::any_of(_groups.begin(), _groups.end(), [](const auto& group) {
- const auto& members = group.getMembers();
- return std::any_of(members.begin(), members.end(),
- [&group](const auto& member) {
- return !Manager::hasOwner(member, group.getInterface());
- });
- }))
+ const auto& members = group.getMembers();
+ return std::any_of(
+ members.begin(), members.end(),
+ [&group](const auto& member) {
+ return !Manager::hasOwner(member, group.getInterface());
+ });
+ }))
{
startTimer();
}
@@ -77,16 +79,18 @@
// If all group members have a given value and it matches what's
// in the cache, start timer and if any do not match, stop
// timer.
- if (std::all_of(_groups.begin(), _groups.end(),
- [&mgr](const auto& group) {
- const auto& members = group.getMembers();
- return std::all_of(members.begin(), members.end(),
- [&mgr, &group](const auto& member) {
- return group.getValue() ==
- mgr->getProperty(member, group.getInterface(),
- group.getProperty());
- });
- }))
+ if (std::all_of(
+ _groups.begin(), _groups.end(), [&mgr](const auto& group) {
+ const auto& members = group.getMembers();
+ return std::all_of(
+ members.begin(), members.end(),
+ [&mgr, &group](const auto& member) {
+ return group.getValue() ==
+ mgr->getProperty(member,
+ group.getInterface(),
+ group.getProperty());
+ });
+ }))
{
// Timer will be started(and never stopped) when _groups is empty
startTimer();
@@ -143,8 +147,8 @@
// Add zone to _actions
std::for_each(_actions.begin(), _actions.end(),
[&zone](std::unique_ptr<ActionBase>& action) {
- action->addZone(zone);
- });
+ action->addZone(zone);
+ });
}
}
diff --git a/control/json/dbus_zone.cpp b/control/json/dbus_zone.cpp
index 6e269c3..a8cbe01 100644
--- a/control/json/dbus_zone.cpp
+++ b/control/json/dbus_zone.cpp
@@ -49,11 +49,11 @@
std::transform(value.begin(), value.end(), value.begin(), toupper);
auto supported = ThermalModeIntf::supported();
- auto isSupported = std::any_of(supported.begin(), supported.end(),
- [&value](auto& s) {
- std::transform(s.begin(), s.end(), s.begin(), toupper);
- return value == s;
- });
+ auto isSupported =
+ std::any_of(supported.begin(), supported.end(), [&value](auto& s) {
+ std::transform(s.begin(), s.end(), s.begin(), toupper);
+ return value == s;
+ });
if (isSupported && value != current)
{
diff --git a/control/json/event.cpp b/control/json/event.cpp
index 628c222..0e7f1e5 100644
--- a/control/json/event.cpp
+++ b/control/json/event.cpp
@@ -40,8 +40,8 @@
Event::Event(const json& jsonObj, Manager* mgr,
std::map<configKey, std::unique_ptr<Zone>>& zones) :
- ConfigBase(jsonObj),
- _bus(util::SDBusPlus::getBus()), _manager(mgr), _zones(zones)
+ ConfigBase(jsonObj), _bus(util::SDBusPlus::getBus()), _manager(mgr),
+ _zones(zones)
{
// Event groups are optional
if (jsonObj.contains("groups"))
@@ -155,10 +155,11 @@
configKey eventProfile =
std::make_pair(jsonGrp["name"].get<std::string>(), profiles);
- auto grpEntry = std::find_if(availGroups.begin(), availGroups.end(),
- [&eventProfile](const auto& grp) {
- return Manager::inConfig(grp.first, eventProfile);
- });
+ auto grpEntry = std::find_if(
+ availGroups.begin(), availGroups.end(),
+ [&eventProfile](const auto& grp) {
+ return Manager::inConfig(grp.first, eventProfile);
+ });
if (grpEntry != availGroups.end())
{
auto group = Group(*grpEntry->second);
@@ -188,12 +189,13 @@
// against all zones matching the event's active profiles
for (const auto& zone : _zones)
{
- configKey eventProfile = std::make_pair(zone.second->getName(),
- _profiles);
- auto zoneEntry = std::find_if(_zones.begin(), _zones.end(),
- [&eventProfile](const auto& z) {
- return Manager::inConfig(z.first, eventProfile);
- });
+ configKey eventProfile =
+ std::make_pair(zone.second->getName(), _profiles);
+ auto zoneEntry = std::find_if(
+ _zones.begin(), _zones.end(),
+ [&eventProfile](const auto& z) {
+ return Manager::inConfig(z.first, eventProfile);
+ });
if (zoneEntry != _zones.end())
{
actionZones.emplace_back(*zoneEntry->second);
@@ -208,10 +210,11 @@
{
configKey eventProfile =
std::make_pair(jsonZone.get<std::string>(), _profiles);
- auto zoneEntry = std::find_if(_zones.begin(), _zones.end(),
- [&eventProfile](const auto& z) {
- return Manager::inConfig(z.first, eventProfile);
- });
+ auto zoneEntry = std::find_if(
+ _zones.begin(), _zones.end(),
+ [&eventProfile](const auto& z) {
+ return Manager::inConfig(z.first, eventProfile);
+ });
if (zoneEntry != _zones.end())
{
actionZones.emplace_back(*zoneEntry->second);
@@ -299,8 +302,8 @@
auto availTrigs = std::accumulate(
std::next(trigger::triggers.begin()), trigger::triggers.end(),
trigger::triggers.begin()->first, [](auto list, auto trig) {
- return std::move(list) + ", " + trig.first;
- });
+ return std::move(list) + ", " + trig.first;
+ });
log<level::ERR>(
std::format("Trigger '{}' is not recognized", tClass).c_str(),
entry("AVAILABLE_TRIGGERS=%s", availTrigs.c_str()));
@@ -314,14 +317,14 @@
json actionData;
std::for_each(_actions.begin(), _actions.end(),
[&actionData](const auto& action) {
- actionData[action->getUniqueName()] = action->dump();
- });
+ actionData[action->getUniqueName()] = action->dump();
+ });
std::vector<std::string> groupData;
std::for_each(_groups.begin(), _groups.end(),
[&groupData](const auto& group) {
- groupData.push_back(group.getName());
- });
+ groupData.push_back(group.getName());
+ });
json eventData;
eventData["groups"] = groupData;
diff --git a/control/json/fan.cpp b/control/json/fan.cpp
index 5abcfbe..a808003 100644
--- a/control/json/fan.cpp
+++ b/control/json/fan.cpp
@@ -155,8 +155,8 @@
// if additional locks, re-lock at next-highest target
if (!_lockedTargets.empty())
{
- itr = std::max_element(_lockedTargets.begin(),
- _lockedTargets.end());
+ itr =
+ std::max_element(_lockedTargets.begin(), _lockedTargets.end());
// setTarget wont work if any locked targets exist
decltype(_lockedTargets) temp;
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index 0161304..6ae51c9 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -168,12 +168,12 @@
auto fans = getConfig<Fan>(false);
for (auto& fan : fans)
{
- configKey fanProfile = std::make_pair(fan.second->getZone(),
- fan.first.second);
- auto itZone = std::find_if(zones.begin(), zones.end(),
- [&fanProfile](const auto& zone) {
- return Manager::inConfig(fanProfile, zone.first);
- });
+ configKey fanProfile =
+ std::make_pair(fan.second->getZone(), fan.first.second);
+ auto itZone = std::find_if(
+ zones.begin(), zones.end(), [&fanProfile](const auto& zone) {
+ return Manager::inConfig(fanProfile, zone.first);
+ });
if (itZone != zones.end())
{
if (itZone->second->getTarget() != fan.second->getTarget() &&
@@ -273,19 +273,21 @@
{
// Profiles must have one match in the other's profiles(and they must be
// an active profile) to be used in the config
- return std::any_of(input.second.begin(), input.second.end(),
- [&comp](const auto& lProfile) {
- return std::any_of(comp.second.begin(), comp.second.end(),
- [&lProfile](const auto& rProfile) {
- if (lProfile != rProfile)
- {
- return false;
- }
- auto activeProfs = getActiveProfiles();
- return std::find(activeProfs.begin(), activeProfs.end(),
- lProfile) != activeProfs.end();
+ return std::any_of(
+ input.second.begin(), input.second.end(),
+ [&comp](const auto& lProfile) {
+ return std::any_of(
+ comp.second.begin(), comp.second.end(),
+ [&lProfile](const auto& rProfile) {
+ if (lProfile != rProfile)
+ {
+ return false;
+ }
+ auto activeProfs = getActiveProfiles();
+ return std::find(activeProfs.begin(), activeProfs.end(),
+ lProfile) != activeProfs.end();
+ });
});
- });
}
}
@@ -416,8 +418,8 @@
if (servIter != pathIter->second.end())
{
if (std::find(servIter->second.second.begin(),
- servIter->second.second.end(),
- intf) == servIter->second.second.end())
+ servIter->second.second.end(), intf) ==
+ servIter->second.second.end())
{
// Add interface to cache
servIter->second.second.emplace_back(intf);
@@ -427,8 +429,8 @@
{
// Service not found in cache
auto intfs = {intf};
- pathIter->second[itServ.first] = std::make_pair(true,
- intfs);
+ pathIter->second[itServ.first] =
+ std::make_pair(true, intfs);
}
}
}
@@ -458,8 +460,8 @@
return serviceName;
}
-std::vector<std::string> Manager::findPaths(const std::string& serv,
- const std::string& intf)
+std::vector<std::string>
+ Manager::findPaths(const std::string& serv, const std::string& intf)
{
std::vector<std::string> paths;
@@ -469,8 +471,8 @@
if (itServ != path.second.end())
{
if (std::find(itServ->second.second.begin(),
- itServ->second.second.end(),
- intf) != itServ->second.second.end())
+ itServ->second.second.end(), intf) !=
+ itServ->second.second.end())
{
if (std::find(paths.begin(), paths.end(), path.first) ==
paths.end())
@@ -598,9 +600,8 @@
}
}
-const std::optional<PropertyVariantType>
- Manager::getProperty(const std::string& path, const std::string& intf,
- const std::string& prop)
+const std::optional<PropertyVariantType> Manager::getProperty(
+ const std::string& path, const std::string& intf, const std::string& prop)
{
// TODO Objects hosted by fan control (i.e. ThermalMode) are required to
// update the cache upon being set/updated
@@ -691,11 +692,11 @@
// Look for the ObjectManager as an ancestor from the
// member.
- auto hasObjMgr = std::any_of(objMgrPaths.begin(),
- objMgrPaths.end(),
- [&member](const auto& path) {
- return member.find(path) != std::string::npos;
- });
+ auto hasObjMgr = std::any_of(
+ objMgrPaths.begin(), objMgrPaths.end(),
+ [&member](const auto& path) {
+ return member.find(path) != std::string::npos;
+ });
if (!hasObjMgr)
{
@@ -756,12 +757,12 @@
// Remove oneshot timers after they expired
if (data.first == TimerType::oneshot)
{
- auto itTimer = std::find_if(_timers.begin(), _timers.end(),
- [&data](const auto& timer) {
- return (data.first == timer.first->first &&
- (std::get<std::string>(data.second) ==
- std::get<std::string>(timer.first->second)));
- });
+ auto itTimer = std::find_if(
+ _timers.begin(), _timers.end(), [&data](const auto& timer) {
+ return (data.first == timer.first->first &&
+ (std::get<std::string>(data.second) ==
+ std::get<std::string>(timer.first->second)));
+ });
if (itTimer != std::end(_timers))
{
_timers.erase(itTimer);
@@ -776,8 +777,8 @@
{
// Handle the signal callback and only run the actions if the handler
// updated the cache for the given SignalObject
- if (std::get<SignalHandler>(pkg)(msg, std::get<SignalObject>(pkg),
- *this))
+ if (std::get<SignalHandler>(
+ pkg)(msg, std::get<SignalObject>(pkg), *this))
{
// Perform the actions in the handler package
auto& actions = std::get<TriggerActions>(pkg);
@@ -799,8 +800,8 @@
void Manager::setProfiles()
{
// Profiles JSON config file is optional
- auto confFile = fan::JsonConfig::getConfFile(confAppName,
- Profile::confFileName, true);
+ auto confFile =
+ fan::JsonConfig::getConfFile(confAppName, Profile::confFileName, true);
_profiles.clear();
if (!confFile.empty())
@@ -834,16 +835,16 @@
{
std::for_each(actions.begin(), actions.end(),
[&actList = it->second](auto& action) {
- actList.emplace_back(std::ref(action));
- });
+ actList.emplace_back(std::ref(action));
+ });
}
else
{
TriggerActions triggerActions;
std::for_each(actions.begin(), actions.end(),
[&triggerActions](auto& action) {
- triggerActions.emplace_back(std::ref(action));
- });
+ triggerActions.emplace_back(std::ref(action));
+ });
_parameterTriggers[name] = std::move(triggerActions);
}
}
diff --git a/control/json/manager.hpp b/control/json/manager.hpp
index d7657e9..2f66181 100644
--- a/control/json/manager.hpp
+++ b/control/json/manager.hpp
@@ -198,8 +198,8 @@
* Map of configuration keys to their corresponding configuration object
*/
template <typename T, typename... Args>
- static std::map<configKey, std::unique_ptr<T>> getConfig(bool isOptional,
- Args&&... args)
+ static std::map<configKey, std::unique_ptr<T>>
+ getConfig(bool isOptional, Args&&... args)
{
std::map<configKey, std::unique_ptr<T>> config;
@@ -226,16 +226,18 @@
if (!profiles.empty() &&
!std::any_of(profiles.begin(), profiles.end(),
[](const auto& name) {
- return std::find(getActiveProfiles().begin(),
- getActiveProfiles().end(),
- name) != getActiveProfiles().end();
- }))
+ return std::find(
+ getActiveProfiles().begin(),
+ getActiveProfiles().end(),
+ name) !=
+ getActiveProfiles().end();
+ }))
{
continue;
}
}
- auto obj = std::make_unique<T>(entry,
- std::forward<Args>(args)...);
+ auto obj =
+ std::make_unique<T>(entry, std::forward<Args>(args)...);
config.emplace(
std::make_pair(obj->getName(), obj->getProfiles()),
std::move(obj));
diff --git a/control/json/profile.cpp b/control/json/profile.cpp
index 7cb818b..0778820 100644
--- a/control/json/profile.cpp
+++ b/control/json/profile.cpp
@@ -60,11 +60,11 @@
else
{
// Construct list of available methods
- auto methods = std::accumulate(std::next(_methods.begin()),
- _methods.end(), _methods.begin()->first,
- [](auto list, auto method) {
- return std::move(list) + ", " + method.first;
- });
+ auto methods = std::accumulate(
+ std::next(_methods.begin()), _methods.end(),
+ _methods.begin()->first, [](auto list, auto method) {
+ return std::move(list) + ", " + method.first;
+ });
log<level::ERR>("Configured method not available",
entry("JSON=%s", jsonObj["method"].dump().c_str()),
entry("METHODS_AVAILABLE=%s", methods.c_str()));
@@ -81,23 +81,26 @@
"Missing required all_of method properties list");
}
- return std::all_of(method["properties"].begin(), method["properties"].end(),
- [](const json& obj) {
- if (!obj.contains("path") || !obj.contains("interface") ||
- !obj.contains("property") || !obj.contains("value"))
- {
- log<level::ERR>(
- "Missing required all_of method property parameters",
- entry("JSON=%s", obj.dump().c_str()));
- throw std::runtime_error(
- "Missing required all_of method parameters");
- }
- auto variant = util::SDBusPlus::getPropertyVariant<PropertyVariantType>(
- obj["path"].get<std::string>(), obj["interface"].get<std::string>(),
- obj["property"].get<std::string>());
+ return std::all_of(
+ method["properties"].begin(), method["properties"].end(),
+ [](const json& obj) {
+ if (!obj.contains("path") || !obj.contains("interface") ||
+ !obj.contains("property") || !obj.contains("value"))
+ {
+ log<level::ERR>(
+ "Missing required all_of method property parameters",
+ entry("JSON=%s", obj.dump().c_str()));
+ throw std::runtime_error(
+ "Missing required all_of method parameters");
+ }
+ auto variant =
+ util::SDBusPlus::getPropertyVariant<PropertyVariantType>(
+ obj["path"].get<std::string>(),
+ obj["interface"].get<std::string>(),
+ obj["property"].get<std::string>());
- return getJsonValue(obj["value"]) == variant;
- });
+ return getJsonValue(obj["value"]) == variant;
+ });
}
} // namespace phosphor::fan::control::json
diff --git a/control/json/triggers/handlers.hpp b/control/json/triggers/handlers.hpp
index 8e8595f..a263295 100644
--- a/control/json/triggers/handlers.hpp
+++ b/control/json/triggers/handlers.hpp
@@ -112,8 +112,8 @@
std::vector<std::string> intfs;
msg.read(intfs);
- auto itIntf = std::find(intfs.begin(), intfs.end(),
- std::get<Intf>(obj));
+ auto itIntf =
+ std::find(intfs.begin(), intfs.end(), std::get<Intf>(obj));
if (itIntf == intfs.cend())
{
// Object's interface not in list of interfaces removed
diff --git a/control/json/triggers/init.cpp b/control/json/triggers/init.cpp
index bd557d7..3d9a535 100644
--- a/control/json/triggers/init.cpp
+++ b/control/json/triggers/init.cpp
@@ -162,8 +162,8 @@
auto availMethods = std::accumulate(
std::next(methods.begin()), methods.end(),
methods.begin()->first, [](auto list, auto method) {
- return std::move(list) + ", " + method.first;
- });
+ return std::move(list) + ", " + method.first;
+ });
auto msg =
std::format("Event '{}' requires a supported method given to "
"be init driven, available methods: {}",
diff --git a/control/json/triggers/signal.cpp b/control/json/triggers/signal.cpp
index 537ef50..c0641d9 100644
--- a/control/json/triggers/signal.cpp
+++ b/control/json/triggers/signal.cpp
@@ -100,13 +100,13 @@
{
// Setup property changed signal handler on the group member's
// property
- const auto match = rules::propertiesChanged(member,
- group.getInterface());
- SignalPkg signalPkg = {Handlers::propertiesChanged,
- SignalObject(std::cref(member),
- std::cref(group.getInterface()),
- std::cref(group.getProperty())),
- actions};
+ const auto match =
+ rules::propertiesChanged(member, group.getInterface());
+ SignalPkg signalPkg = {
+ Handlers::propertiesChanged,
+ SignalObject(std::cref(member), std::cref(group.getInterface()),
+ std::cref(group.getProperty())),
+ actions};
auto isSameSig = [&prop = group.getProperty()](SignalPkg& pkg) {
auto& obj = std::get<SignalObject>(pkg);
return prop == std::get<Prop>(obj);
@@ -124,13 +124,13 @@
for (const auto& member : group.getMembers())
{
// Setup interfaces added signal handler on the group member
- const auto match = rules::interfacesAdded() +
- rules::argNpath(0, member);
- SignalPkg signalPkg = {Handlers::interfacesAdded,
- SignalObject(std::cref(member),
- std::cref(group.getInterface()),
- std::cref(group.getProperty())),
- actions};
+ const auto match =
+ rules::interfacesAdded() + rules::argNpath(0, member);
+ SignalPkg signalPkg = {
+ Handlers::interfacesAdded,
+ SignalObject(std::cref(member), std::cref(group.getInterface()),
+ std::cref(group.getProperty())),
+ actions};
auto isSameSig = [&intf = group.getInterface()](SignalPkg& pkg) {
auto& obj = std::get<SignalObject>(pkg);
return intf == std::get<Intf>(obj);
@@ -148,13 +148,13 @@
for (const auto& member : group.getMembers())
{
// Setup interfaces removed signal handler on the group member
- const auto match = rules::interfacesRemoved() +
- rules::argNpath(0, member);
- SignalPkg signalPkg = {Handlers::interfacesRemoved,
- SignalObject(std::cref(member),
- std::cref(group.getInterface()),
- std::cref(group.getProperty())),
- actions};
+ const auto match =
+ rules::interfacesRemoved() + rules::argNpath(0, member);
+ SignalPkg signalPkg = {
+ Handlers::interfacesRemoved,
+ SignalObject(std::cref(member), std::cref(group.getInterface()),
+ std::cref(group.getProperty())),
+ actions};
auto isSameSig = [&intf = group.getInterface()](SignalPkg& pkg) {
auto& obj = std::get<SignalObject>(pkg);
return intf == std::get<Intf>(obj);
@@ -252,8 +252,8 @@
auto availSignals =
std::accumulate(std::next(signals.begin()), signals.end(),
signals.begin()->first, [](auto list, auto signal) {
- return std::move(list) + ", " + signal.first;
- });
+ return std::move(list) + ", " + signal.first;
+ });
auto msg =
std::format("Event '{}' requires a supported signal given to be "
"triggered by signal, available signals: {}",
@@ -269,8 +269,8 @@
TriggerActions signalActions;
std::for_each(actions.begin(), actions.end(),
[&signalActions](auto& action) {
- signalActions.emplace_back(std::ref(action));
- });
+ signalActions.emplace_back(std::ref(action));
+ });
for (const auto& group : groups)
{
// Call signal subscriber for each group
diff --git a/control/json/utils/flight_recorder.cpp b/control/json/utils/flight_recorder.cpp
index 00325f5..b26d2d8 100644
--- a/control/json/utils/flight_recorder.cpp
+++ b/control/json/utils/flight_recorder.cpp
@@ -70,8 +70,8 @@
std::sort(output.begin(), output.end(),
[](const auto& left, const auto& right) {
- return std::get<Timepoint>(left) < std::get<Timepoint>(right);
- });
+ return std::get<Timepoint>(left) < std::get<Timepoint>(right);
+ });
auto formatTime = [](const Timepoint& tp) {
std::stringstream ss;
diff --git a/control/json/utils/pcie_card_metadata.cpp b/control/json/utils/pcie_card_metadata.cpp
index ec6452c..c8c1b37 100644
--- a/control/json/utils/pcie_card_metadata.cpp
+++ b/control/json/utils/pcie_card_metadata.cpp
@@ -112,10 +112,10 @@
}
Metadata data;
- data.vendorID = std::stoul(card.at("vendor_id").get<std::string>(),
- nullptr, 16);
- data.deviceID = std::stoul(card.at("device_id").get<std::string>(),
- nullptr, 16);
+ data.vendorID =
+ std::stoul(card.at("vendor_id").get<std::string>(), nullptr, 16);
+ data.deviceID =
+ std::stoul(card.at("device_id").get<std::string>(), nullptr, 16);
data.subsystemVendorID = std::stoul(
card.at("subsystem_vendor_id").get<std::string>(), nullptr, 16);
data.subsystemID =
@@ -157,21 +157,21 @@
}
}
-std::optional<std::variant<int32_t, bool>>
- PCIeCardMetadata::lookup(uint16_t deviceID, uint16_t vendorID,
- uint16_t subsystemID,
- uint16_t subsystemVendorID) const
+std::optional<std::variant<int32_t, bool>> PCIeCardMetadata::lookup(
+ uint16_t deviceID, uint16_t vendorID, uint16_t subsystemID,
+ uint16_t subsystemVendorID) const
{
log<level::DEBUG>(std::format("Lookup {:#x} ${:#x} {:#x} {:#x}", deviceID,
vendorID, subsystemID, subsystemVendorID)
.c_str());
- auto card = std::find_if(_cards.begin(), _cards.end(),
- [&deviceID, &vendorID, &subsystemID,
- &subsystemVendorID](const auto& card) {
- return (deviceID == card.deviceID) && (vendorID == card.vendorID) &&
- (subsystemID == card.subsystemID) &&
- (subsystemVendorID == card.subsystemVendorID);
- });
+ auto card = std::find_if(
+ _cards.begin(), _cards.end(),
+ [&deviceID, &vendorID, &subsystemID,
+ &subsystemVendorID](const auto& card) {
+ return (deviceID == card.deviceID) && (vendorID == card.vendorID) &&
+ (subsystemID == card.subsystemID) &&
+ (subsystemVendorID == card.subsystemVendorID);
+ });
if (card != _cards.end())
{
diff --git a/control/json/zone.cpp b/control/json/zone.cpp
index 12f8c02..8dc6044 100644
--- a/control/json/zone.cpp
+++ b/control/json/zone.cpp
@@ -161,9 +161,10 @@
void Zone::lockFanTarget(const std::string& fname, uint64_t target)
{
- auto fanItr = std::find_if(
- _fans.begin(), _fans.end(),
- [&fname](const auto& fan) { return fan->getName() == fname; });
+ auto fanItr =
+ std::find_if(_fans.begin(), _fans.end(), [&fname](const auto& fan) {
+ return fan->getName() == fname;
+ });
if (_fans.end() != fanItr)
{
@@ -180,9 +181,10 @@
void Zone::unlockFanTarget(const std::string& fname, uint64_t target)
{
- auto fanItr = std::find_if(
- _fans.begin(), _fans.end(),
- [&fname](const auto& fan) { return fan->getName() == fname; });
+ auto fanItr =
+ std::find_if(_fans.begin(), _fans.end(), [&fname](const auto& fan) {
+ return fan->getName() == fname;
+ });
if (_fans.end() != fanItr)
{
@@ -230,8 +232,8 @@
auto itHoldMax = std::max_element(_targetHolds.begin(), _targetHolds.end(),
[](const auto& aHold, const auto& bHold) {
- return aHold.second < bHold.second;
- });
+ return aHold.second < bHold.second;
+ });
if (itHoldMax == _targetHolds.end())
{
_isActive = true;
@@ -293,8 +295,8 @@
auto itHoldMax = std::max_element(_floorHolds.begin(), _floorHolds.end(),
[](const auto& aHold, const auto& bHold) {
- return aHold.second < bHold.second;
- });
+ return aHold.second < bHold.second;
+ });
if (itHoldMax == _floorHolds.end())
{
if (_floor != _defaultFloor)
@@ -461,8 +463,8 @@
auto intfs = std::accumulate(
std::next(_intfPropHandlers.begin()), _intfPropHandlers.end(),
_intfPropHandlers.begin()->first, [](auto list, auto intf) {
- return std::move(list) + ", " + intf.first;
- });
+ return std::move(list) + ", " + intf.first;
+ });
log<level::ERR>("Configured interface not available",
entry("JSON=%s", interface.dump().c_str()),
entry("AVAILABLE_INTFS=%s", intfs.c_str()));
@@ -496,8 +498,8 @@
std::next(propFuncs->second.begin()),
propFuncs->second.end(), propFuncs->second.begin()->first,
[](auto list, auto prop) {
- return std::move(list) + ", " + prop.first;
- });
+ return std::move(list) + ", " + prop.first;
+ });
log<level::ERR>("Configured property not available",
entry("JSON=%s", property.dump().c_str()),
entry("AVAILABLE_PROPS=%s", props.c_str()));
@@ -556,8 +558,8 @@
{
// Get a set property handler function for the configured values of the
// "Supported" property
-std::function<void(DBusZone&, Zone&)> supported(const json& jsonObj,
- bool persist)
+std::function<void(DBusZone&, Zone&)>
+ supported(const json& jsonObj, bool persist)
{
std::vector<std::string> values;
if (!jsonObj.contains("values"))
diff --git a/control/json/zone.hpp b/control/json/zone.hpp
index 21fccbc..bb00416 100644
--- a/control/json/zone.hpp
+++ b/control/json/zone.hpp
@@ -381,8 +381,8 @@
static auto setProperty(const char* intf, const char* prop,
T (DBusZone::*func)(T), T&& value, bool persist)
{
- return [=, value = std::forward<T>(value)](DBusZone& dbusZone,
- Zone& zone) {
+ return [=, value =
+ std::forward<T>(value)](DBusZone& dbusZone, Zone& zone) {
(dbusZone.*func)(value);
if (persist)
{
@@ -551,8 +551,8 @@
*
* @return Zone dbus object's set property function for the "Supported" property
*/
-std::function<void(DBusZone&, Zone&)> supported(const json& jsonObj,
- bool persist);
+std::function<void(DBusZone&, Zone&)>
+ supported(const json& jsonObj, bool persist);
/**
* @brief "Current" property on the "xyz.openbmc_project.Control.ThermalMode"
@@ -564,8 +564,8 @@
*
* @return Zone dbus object's set property function for the "Current" property
*/
-std::function<void(DBusZone&, Zone&)> current(const json& jsonObj,
- bool persist);
+std::function<void(DBusZone&, Zone&)>
+ current(const json& jsonObj, bool persist);
} // namespace zone::property
diff --git a/control/main.cpp b/control/main.cpp
index e28e947..9286dc7 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -90,8 +90,8 @@
try
{
#ifdef CONTROL_USE_JSON
- phosphor::fan::control::json::FlightRecorder::instance().log("main",
- "Startup");
+ phosphor::fan::control::json::FlightRecorder::instance().log(
+ "main", "Startup");
json::Manager manager(event);
// Handle loading fan control's config file(s)
diff --git a/control/manager.cpp b/control/manager.cpp
index 27c3b47..abcad6f 100644
--- a/control/manager.cpp
+++ b/control/manager.cpp
@@ -83,9 +83,7 @@
// Note: Future code will check 'mode' before starting control algorithm
Manager::Manager(sdbusplus::bus_t& bus, const sdeventplus::Event& event,
- Mode mode) :
- _bus(bus),
- _objMgr(bus, CONTROL_OBJPATH)
+ Mode mode) : _bus(bus), _objMgr(bus, CONTROL_OBJPATH)
{
// Create the appropriate Zone objects based on the
// actual system configuration.
@@ -97,8 +95,8 @@
if (std::all_of(conditions.begin(), conditions.end(),
[&bus](const auto& condition) {
- return checkCondition(bus, condition);
- }))
+ return checkCondition(bus, condition);
+ }))
{
// Create a Zone object for each zone in this group
auto& zones = std::get<zoneListPos>(group);
diff --git a/control/preconditions.cpp b/control/preconditions.cpp
index 6365d41..13f51db 100644
--- a/control/preconditions.cpp
+++ b/control/preconditions.cpp
@@ -23,21 +23,22 @@
{
return [pg = std::move(pg), sse = std::move(sse)](auto& zone, auto& group) {
// Compare given precondition entries
- auto precondState = std::all_of(pg.begin(), pg.end(),
- [&zone](auto const& entry) {
- try
- {
- return zone.getPropValueVariant(std::get<pcPathPos>(entry),
- std::get<pcIntfPos>(entry),
- std::get<pcPropPos>(entry)) ==
- std::get<pcValuePos>(entry);
- }
- catch (const std::out_of_range& oore)
- {
- // Default to property variants not equal when not found
- return false;
- }
- });
+ auto precondState =
+ std::all_of(pg.begin(), pg.end(), [&zone](const auto& entry) {
+ try
+ {
+ return zone.getPropValueVariant(
+ std::get<pcPathPos>(entry),
+ std::get<pcIntfPos>(entry),
+ std::get<pcPropPos>(entry)) ==
+ std::get<pcValuePos>(entry);
+ }
+ catch (const std::out_of_range& oore)
+ {
+ // Default to property variants not equal when not found
+ return false;
+ }
+ });
if (precondState)
{
@@ -45,7 +46,7 @@
"Preconditions passed, init the associated events",
entry("EVENT_COUNT=%u", sse.size()));
// Init the events when all the precondition(s) are true
- std::for_each(sse.begin(), sse.end(), [&zone](auto const& entry) {
+ std::for_each(sse.begin(), sse.end(), [&zone](const auto& entry) {
zone.initEvent(entry);
});
}
@@ -55,7 +56,7 @@
"Preconditions not met for events, events removed if present",
entry("EVENT_COUNT=%u", sse.size()));
// Unsubscribe the events' signals when any precondition is false
- std::for_each(sse.begin(), sse.end(), [&zone](auto const& entry) {
+ std::for_each(sse.begin(), sse.end(), [&zone](const auto& entry) {
zone.removeEvent(entry);
});
zone.setFullSpeed();
@@ -71,21 +72,22 @@
// Set/update the services of the group
zone.setServices(&group);
const auto& services = zone.getGroupServices(&group);
- auto precondState = std::any_of(
- services.begin(), services.end(),
- [](const auto& s) { return !std::get<hasOwnerPos>(s); });
+ auto precondState =
+ std::any_of(services.begin(), services.end(), [](const auto& s) {
+ return !std::get<hasOwnerPos>(s);
+ });
if (precondState)
{
// Init the events when all the precondition(s) are true
- std::for_each(sse.begin(), sse.end(), [&zone](auto const& entry) {
+ std::for_each(sse.begin(), sse.end(), [&zone](const auto& entry) {
zone.initEvent(entry);
});
}
else
{
// Unsubscribe the events' signals when any precondition is false
- std::for_each(sse.begin(), sse.end(), [&zone](auto const& entry) {
+ std::for_each(sse.begin(), sse.end(), [&zone](const auto& entry) {
zone.removeEvent(entry);
});
}
diff --git a/control/triggers.cpp b/control/triggers.cpp
index 362f4b6..0096deb 100644
--- a/control/triggers.cpp
+++ b/control/triggers.cpp
@@ -74,9 +74,10 @@
}
// Run action functions for initial event state
- std::for_each(
- actions.begin(), actions.end(),
- [&zone, &group](auto const& action) { action(zone, group); });
+ std::for_each(actions.begin(), actions.end(),
+ [&zone, &group](const auto& action) {
+ action(zone, group);
+ });
};
}
diff --git a/control/zone.cpp b/control/zone.cpp
index b1badc1..6031d53 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -144,8 +144,8 @@
auto& sNames = _services.at(*group);
auto it = std::find_if(sNames.begin(), sNames.end(),
[&name](const auto& entry) {
- return name == std::get<namePos>(entry);
- });
+ return name == std::get<namePos>(entry);
+ });
if (it != std::end(sNames))
{
// Remove service name from group
@@ -166,8 +166,8 @@
auto& sNames = _services.at(*group);
auto it = std::find_if(sNames.begin(), sNames.end(),
[&name](const auto& entry) {
- return name == std::get<namePos>(entry);
- });
+ return name == std::get<namePos>(entry);
+ });
if (it != std::end(sNames))
{
std::get<hasOwnerPos>(*it) = hasOwner;
@@ -299,35 +299,36 @@
void Zone::initEvent(const SetSpeedEvent& event)
{
// Enable event triggers
- std::for_each(std::get<triggerPos>(event).begin(),
- std::get<triggerPos>(event).end(),
- [this, &event](const auto& trigger) {
- if (!std::get<actionsPos>(event).empty())
- {
- std::for_each(std::get<actionsPos>(event).begin(),
- std::get<actionsPos>(event).end(),
- [this, &trigger, &event](auto const& action) {
- // Default to use group defined with action if exists
- if (!std::get<adGroupPos>(action).empty())
- {
- trigger(*this, std::get<sseNamePos>(event),
- std::get<adGroupPos>(action),
- std::get<adActionsPos>(action));
- }
- else
- {
- trigger(*this, std::get<sseNamePos>(event),
- std::get<groupPos>(event),
- std::get<adActionsPos>(action));
- }
- });
- }
- else
- {
- trigger(*this, std::get<sseNamePos>(event),
- std::get<groupPos>(event), {});
- }
- });
+ std::for_each(
+ std::get<triggerPos>(event).begin(), std::get<triggerPos>(event).end(),
+ [this, &event](const auto& trigger) {
+ if (!std::get<actionsPos>(event).empty())
+ {
+ std::for_each(
+ std::get<actionsPos>(event).begin(),
+ std::get<actionsPos>(event).end(),
+ [this, &trigger, &event](const auto& action) {
+ // Default to use group defined with action if exists
+ if (!std::get<adGroupPos>(action).empty())
+ {
+ trigger(*this, std::get<sseNamePos>(event),
+ std::get<adGroupPos>(action),
+ std::get<adActionsPos>(action));
+ }
+ else
+ {
+ trigger(*this, std::get<sseNamePos>(event),
+ std::get<groupPos>(event),
+ std::get<adActionsPos>(action));
+ }
+ });
+ }
+ else
+ {
+ trigger(*this, std::get<sseNamePos>(event),
+ std::get<groupPos>(event), {});
+ }
+ });
}
void Zone::removeEvent(const SetSpeedEvent& event)
@@ -352,10 +353,9 @@
}
}
-std::vector<TimerEvent>::iterator
- Zone::findTimer(const Group& eventGroup,
- const std::vector<Action>& eventActions,
- std::vector<TimerEvent>& eventTimers)
+std::vector<TimerEvent>::iterator Zone::findTimer(
+ const Group& eventGroup, const std::vector<Action>& eventActions,
+ std::vector<TimerEvent>& eventTimers)
{
for (auto it = eventTimers.begin(); it != eventTimers.end(); ++it)
{
@@ -409,9 +409,10 @@
const std::vector<Action>& eventActions)
{
// Perform the actions
- std::for_each(
- eventActions.begin(), eventActions.end(),
- [this, &eventGroup](const auto& action) { action(*this, eventGroup); });
+ std::for_each(eventActions.begin(), eventActions.end(),
+ [this, &eventGroup](const auto& action) {
+ action(*this, eventGroup);
+ });
}
void Zone::handleEvent(sdbusplus::message_t& msg, const EventData* eventData)
@@ -422,8 +423,8 @@
std::for_each(std::get<eventActionsPos>(*eventData).begin(),
std::get<eventActionsPos>(*eventData).end(),
[this, &eventData](const auto& action) {
- action(*this, std::get<eventGroupPos>(*eventData));
- });
+ action(*this, std::get<eventGroupPos>(*eventData));
+ });
}
const std::string& Zone::getService(const std::string& path,
@@ -478,8 +479,8 @@
for (auto& iIter : sIter.second)
{
if (std::find(servIter->second.begin(),
- servIter->second.end(),
- iIter) == servIter->second.end())
+ servIter->second.end(), iIter) ==
+ servIter->second.end())
{
// Add interface to cache
servIter->second.emplace_back(iIter);
@@ -533,11 +534,11 @@
std::transform(value.begin(), value.end(), value.begin(), toupper);
auto supported = ThermalObject::supported();
- auto isSupported = std::any_of(supported.begin(), supported.end(),
- [&value](auto& s) {
- std::transform(s.begin(), s.end(), s.begin(), toupper);
- return value == s;
- });
+ auto isSupported =
+ std::any_of(supported.begin(), supported.end(), [&value](auto& s) {
+ std::transform(s.begin(), s.end(), s.begin(), toupper);
+ return value == s;
+ });
if (value != current && isSupported)
{
diff --git a/control/zone.hpp b/control/zone.hpp
index ce9c6bf..dfa6efb 100644
--- a/control/zone.hpp
+++ b/control/zone.hpp
@@ -241,24 +241,24 @@
std::optional<T> value;
std::visit(
[&value](auto&& val) {
- // If the type configured is int64, but the sensor value
- // property's type is double, scale it by 1000 and return
- // the value as an int64 as configured.
- using V = std::decay_t<decltype(val)>;
- if constexpr (std::is_same_v<T, int64_t> &&
- std::is_same_v<V, double>)
- {
- val = val * 1000;
- value = std::lround(val);
- }
- // If the type configured matches the sensor value
- // property's type, just return the value as its
- // given type.
- else if constexpr (std::is_same_v<T, V>)
- {
- value = val;
- }
- },
+ // If the type configured is int64, but the sensor value
+ // property's type is double, scale it by 1000 and return
+ // the value as an int64 as configured.
+ using V = std::decay_t<decltype(val)>;
+ if constexpr (std::is_same_v<T, int64_t> &&
+ std::is_same_v<V, double>)
+ {
+ val = val * 1000;
+ value = std::lround(val);
+ }
+ // If the type configured matches the sensor value
+ // property's type, just return the value as its
+ // given type.
+ else if constexpr (std::is_same_v<T, V>)
+ {
+ value = val;
+ }
+ },
variant);
// Unable to return Sensor Value property
@@ -504,10 +504,9 @@
*
* @return - Iterator to the timer event
*/
- std::vector<TimerEvent>::iterator
- findTimer(const Group& eventGroup,
- const std::vector<Action>& eventActions,
- std::vector<TimerEvent>& eventTimers);
+ std::vector<TimerEvent>::iterator findTimer(
+ const Group& eventGroup, const std::vector<Action>& eventActions,
+ std::vector<TimerEvent>& eventTimers);
/**
* @brief Add a timer to the list of timer based events
@@ -628,12 +627,12 @@
// type(T) is available on this interface and read it
std::visit(
[&value](auto&& val) {
- using V = std::decay_t<decltype(val)>;
- if constexpr (std::is_same_v<T, V>)
- {
- value = val;
- }
- },
+ using V = std::decay_t<decltype(val)>;
+ if constexpr (std::is_same_v<T, V>)
+ {
+ value = val;
+ }
+ },
var);
return value;
diff --git a/cooling-type/cooling_type.cpp b/cooling-type/cooling_type.cpp
index 2df84bd..3b83bec 100644
--- a/cooling-type/cooling_type.cpp
+++ b/cooling-type/cooling_type.cpp
@@ -65,8 +65,8 @@
auto gpioDev = evdevOpen(gpioFd());
int value = 0;
- auto fetch_rc = libevdev_fetch_event_value(gpioDev.get(), EV_KEY, keycode,
- &value);
+ auto fetch_rc =
+ libevdev_fetch_event_value(gpioDev.get(), EV_KEY, keycode, &value);
if (0 == fetch_rc)
{
log<level::ERR>(
diff --git a/cooling-type/main.cpp b/cooling-type/main.cpp
index 2c31757..402e632 100644
--- a/cooling-type/main.cpp
+++ b/cooling-type/main.cpp
@@ -82,14 +82,14 @@
}
catch (const DBusMethodError& dme)
{
- log<level::ERR>(std::format("Uncaught DBus method failure exception "
- "Busname: {} "
- "Path: {} "
- "Interface: {} "
- "Method: {}",
- dme.busName, dme.path, dme.interface,
- dme.method)
- .c_str());
+ log<level::ERR>(
+ std::format("Uncaught DBus method failure exception "
+ "Busname: {} "
+ "Path: {} "
+ "Interface: {} "
+ "Method: {}",
+ dme.busName, dme.path, dme.interface, dme.method)
+ .c_str());
}
catch (const std::exception& err)
{
diff --git a/json_config.hpp b/json_config.hpp
index 04deb6b..52dd505 100644
--- a/json_config.hpp
+++ b/json_config.hpp
@@ -263,13 +263,13 @@
// Look for a config file at each entry relative to the base
// path and use the first one found
- auto it =
- std::find_if(_confCompatValues.begin(), _confCompatValues.end(),
- [&confFile, &appName, &fileName](const auto& value) {
- confFile = fs::path{confBasePath} / appName / value / fileName;
- _compatibleName = value;
- return fs::exists(confFile);
- });
+ auto it = std::find_if(
+ _confCompatValues.begin(), _confCompatValues.end(),
+ [&confFile, &appName, &fileName](const auto& value) {
+ confFile = fs::path{confBasePath} / appName / value / fileName;
+ _compatibleName = value;
+ return fs::exists(confFile);
+ });
if (it == _confCompatValues.end())
{
confFile.clear();
diff --git a/monitor/conditions.cpp b/monitor/conditions.cpp
index 35fb7a3..62e272c 100644
--- a/monitor/conditions.cpp
+++ b/monitor/conditions.cpp
@@ -23,13 +23,13 @@
Condition propertiesMatch(std::vector<PropertyState>&& propStates)
{
return [pStates = std::move(propStates)](sdbusplus::bus_t& bus) {
- return std::all_of(pStates.begin(), pStates.end(),
- [&bus](const auto& p) {
- return util::SDBusPlus::getPropertyVariant<PropertyValue>(
- bus, std::get<propObj>(p.first),
- std::get<propIface>(p.first),
- std::get<propName>(p.first)) == p.second;
- });
+ return std::all_of(
+ pStates.begin(), pStates.end(), [&bus](const auto& p) {
+ return util::SDBusPlus::getPropertyVariant<PropertyValue>(
+ bus, std::get<propObj>(p.first),
+ std::get<propIface>(p.first),
+ std::get<propName>(p.first)) == p.second;
+ });
};
}
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 0589593..a9ca013 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -38,8 +38,7 @@
Fan::Fan(Mode mode, sdbusplus::bus_t& bus, const sdeventplus::Event& event,
std::unique_ptr<trust::Manager>& trust, const FanDefinition& def,
System& system) :
- _bus(bus),
- _name(def.name), _deviation(def.deviation),
+ _bus(bus), _name(def.name), _deviation(def.deviation),
_upperDeviation(def.upperDeviation),
_numSensorFailsForNonFunc(def.numSensorFailsForNonfunc),
_trustManager(trust),
@@ -332,8 +331,9 @@
uint64_t target = 0;
// The sensor doesn't support a target,
// so get it from another sensor.
- auto s = std::find_if(_sensors.begin(), _sensors.end(),
- [](const auto& s) { return s->hasTarget(); });
+ auto s = std::find_if(_sensors.begin(), _sensors.end(), [](const auto& s) {
+ return s->hasTarget();
+ });
if (s != _sensors.end())
{
@@ -345,8 +345,9 @@
size_t Fan::countNonFunctionalSensors() const
{
- return std::count_if(_sensors.begin(), _sensors.end(),
- [](const auto& s) { return !s->functional(); });
+ return std::count_if(_sensors.begin(), _sensors.end(), [](const auto& s) {
+ return !s->functional();
+ });
}
bool Fan::outOfRange(const TachSensor& sensor)
diff --git a/monitor/fan_error.cpp b/monitor/fan_error.cpp
index 396b731..6d0ef20 100644
--- a/monitor/fan_error.cpp
+++ b/monitor/fan_error.cpp
@@ -255,8 +255,8 @@
message = getFieldValue(journal, "MESSAGE");
// Build one line string containing field values
- entries.push_back(timeStamp + " " + syslogID + "[" + pid +
- "]: " + message);
+ entries.push_back(
+ timeStamp + " " + syslogID + "[" + pid + "]: " + message);
// Stop after number of lines was read
if (count++ >= numLines)
diff --git a/monitor/fan_error.hpp b/monitor/fan_error.hpp
index 1f36c2f..446e513 100644
--- a/monitor/fan_error.hpp
+++ b/monitor/fan_error.hpp
@@ -97,8 +97,7 @@
const std::string& sensor,
sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level
severity) :
- _errorName(error),
- _fanName(fan), _sensorName(sensor),
+ _errorName(error), _fanName(fan), _sensorName(sensor),
_severity(
sdbusplus::xyz::openbmc_project::Logging::server::convertForMessage(
severity))
diff --git a/monitor/json_parser.cpp b/monitor/json_parser.cpp
index 20a3bcb..5faccb4 100644
--- a/monitor/json_parser.cpp
+++ b/monitor/json_parser.cpp
@@ -176,14 +176,15 @@
ignoreAboveMax = sensor["ignore_above_max"].get<bool>();
}
- SensorDefinition def{.name = sensor["name"].get<std::string>(),
- .hasTarget = sensor["has_target"].get<bool>(),
- .targetInterface = targetIntf,
- .targetPath = targetPath,
- .factor = factor,
- .offset = offset,
- .threshold = threshold,
- .ignoreAboveMax = ignoreAboveMax};
+ SensorDefinition def{
+ .name = sensor["name"].get<std::string>(),
+ .hasTarget = sensor["has_target"].get<bool>(),
+ .targetInterface = targetIntf,
+ .targetPath = targetPath,
+ .factor = factor,
+ .offset = offset,
+ .threshold = threshold,
+ .ignoreAboveMax = ignoreAboveMax};
sensorDefs.push_back(std::move(def));
}
@@ -373,20 +374,21 @@
setFuncOnPresent = fan["set_func_on_present"].get<bool>();
}
- FanDefinition def{.name = fan["inventory"].get<std::string>(),
- .method = method,
- .funcDelay = funcDelay,
- .timeout = timeout,
- .deviation = deviation,
- .upperDeviation = upperDeviation,
- .numSensorFailsForNonfunc = nonfuncSensorsCount,
- .monitorStartDelay = monitorDelay,
- .countInterval = countInterval,
- .nonfuncRotorErrDelay = nonfuncRotorErrorDelay,
- .fanMissingErrDelay = fanMissingErrorDelay,
- .sensorList = std::move(sensorDefs),
- .condition = cond,
- .funcOnPresent = setFuncOnPresent};
+ FanDefinition def{
+ .name = fan["inventory"].get<std::string>(),
+ .method = method,
+ .funcDelay = funcDelay,
+ .timeout = timeout,
+ .deviation = deviation,
+ .upperDeviation = upperDeviation,
+ .numSensorFailsForNonfunc = nonfuncSensorsCount,
+ .monitorStartDelay = monitorDelay,
+ .countInterval = countInterval,
+ .nonfuncRotorErrDelay = nonfuncRotorErrorDelay,
+ .fanMissingErrDelay = fanMissingErrorDelay,
+ .sensorList = std::move(sensorDefs),
+ .condition = cond,
+ .funcOnPresent = setFuncOnPresent};
fanDefs.push_back(std::move(def));
}
@@ -438,11 +440,11 @@
[count]() { return std::make_unique<MissingFanFRUCause>(count); }},
{"nonfunc_fan_rotors",
[count]() {
- return std::make_unique<NonfuncFanRotorCause>(count);
- }},
+ return std::make_unique<NonfuncFanRotorCause>(count);
+ }},
{"fan_frus_with_nonfunc_rotors", [count]() {
- return std::make_unique<FanFRUsWithNonfuncRotorsCause>(count);
- }}};
+ return std::make_unique<FanFRUsWithNonfuncRotorsCause>(count);
+ }}};
auto it = causes.find(powerOffCause);
if (it != causes.end())
@@ -512,8 +514,8 @@
}
else
{
- auto msg = std::format("Invalid 'type' entry {} in power off config",
- type);
+ auto msg =
+ std::format("Invalid 'type' entry {} in power off config", type);
log<level::ERR>(msg.c_str());
throw std::runtime_error(msg.c_str());
}
@@ -521,10 +523,9 @@
return action;
}
-std::vector<std::unique_ptr<PowerOffRule>>
- getPowerOffRules(const json& obj,
- std::shared_ptr<PowerInterfaceBase>& powerInterface,
- PowerOffAction::PrePowerOffFunc& func)
+std::vector<std::unique_ptr<PowerOffRule>> getPowerOffRules(
+ const json& obj, std::shared_ptr<PowerInterfaceBase>& powerInterface,
+ PowerOffAction::PrePowerOffFunc& func)
{
std::vector<std::unique_ptr<PowerOffRule>> rules;
diff --git a/monitor/json_parser.hpp b/monitor/json_parser.hpp
index 7f09fd3..30e9d02 100644
--- a/monitor/json_parser.hpp
+++ b/monitor/json_parser.hpp
@@ -92,10 +92,9 @@
* @return std::vector<std::unique_ptr<PowerOffRule>> -
* The PowerOffRule objects
*/
-std::vector<std::unique_ptr<PowerOffRule>>
- getPowerOffRules(const json& obj,
- std::shared_ptr<PowerInterfaceBase>& powerInterface,
- PowerOffAction::PrePowerOffFunc& func);
+std::vector<std::unique_ptr<PowerOffRule>> getPowerOffRules(
+ const json& obj, std::shared_ptr<PowerInterfaceBase>& powerInterface,
+ PowerOffAction::PrePowerOffFunc& func);
/**
* @brief Returns the 'num_nonfunc_rotors_before_error field
diff --git a/monitor/main.cpp b/monitor/main.cpp
index 8505c76..8c60f08 100644
--- a/monitor/main.cpp
+++ b/monitor/main.cpp
@@ -80,10 +80,10 @@
// Enable SIGHUP handling to reload JSON config
stdplus::signal::block(SIGHUP);
- sdeventplus::source::Signal signal(event, SIGHUP,
- std::bind(&System::sighupHandler,
- &system, std::placeholders::_1,
- std::placeholders::_2));
+ sdeventplus::source::Signal signal(
+ event, SIGHUP,
+ std::bind(&System::sighupHandler, &system, std::placeholders::_1,
+ std::placeholders::_2));
// Enable SIGUSR1 handling to dump debug data
stdplus::signal::block(SIGUSR1);
diff --git a/monitor/power_off_action.hpp b/monitor/power_off_action.hpp
index 6d7580b..348173b 100644
--- a/monitor/power_off_action.hpp
+++ b/monitor/power_off_action.hpp
@@ -54,8 +54,7 @@
PowerOffAction(const std::string& name,
std::shared_ptr<PowerInterfaceBase> powerInterface,
PrePowerOffFunc& powerOffFunc) :
- _name(name),
- _powerIface(std::move(powerInterface)),
+ _name(name), _powerIface(std::move(powerInterface)),
_event(sdeventplus::Event::get_default()),
_prePowerOffFunc(powerOffFunc)
{}
diff --git a/monitor/power_off_cause.hpp b/monitor/power_off_cause.hpp
index bc3704f..abc2cb4 100644
--- a/monitor/power_off_cause.hpp
+++ b/monitor/power_off_cause.hpp
@@ -109,10 +109,10 @@
*/
bool satisfied(const FanHealth& fanHealth) override
{
- size_t count = std::count_if(fanHealth.begin(), fanHealth.end(),
- [](const auto& fan) {
- return !std::get<presentHealthPos>(fan.second);
- });
+ size_t count = std::count_if(
+ fanHealth.begin(), fanHealth.end(), [](const auto& fan) {
+ return !std::get<presentHealthPos>(fan.second);
+ });
return count >= _count;
}
@@ -152,13 +152,15 @@
*/
bool satisfied(const FanHealth& fanHealth) override
{
- size_t count = std::accumulate(fanHealth.begin(), fanHealth.end(), 0,
- [](int sum, const auto& fan) {
- const auto& tachs = std::get<sensorFuncHealthPos>(fan.second);
- auto nonFuncTachs = std::count_if(tachs.begin(), tachs.end(),
- [](bool tach) { return !tach; });
- return sum + nonFuncTachs;
- });
+ size_t count = std::accumulate(
+ fanHealth.begin(), fanHealth.end(), 0,
+ [](int sum, const auto& fan) {
+ const auto& tachs = std::get<sensorFuncHealthPos>(fan.second);
+ auto nonFuncTachs =
+ std::count_if(tachs.begin(), tachs.end(),
+ [](bool tach) { return !tach; });
+ return sum + nonFuncTachs;
+ });
return count >= _count;
}
@@ -201,13 +203,13 @@
*/
bool satisfied(const FanHealth& fanHealth) override
{
- size_t count = std::count_if(fanHealth.begin(), fanHealth.end(),
- [](const auto& fan) {
- const auto& tachs = std::get<sensorFuncHealthPos>(fan.second);
+ size_t count = std::count_if(
+ fanHealth.begin(), fanHealth.end(), [](const auto& fan) {
+ const auto& tachs = std::get<sensorFuncHealthPos>(fan.second);
- return std::any_of(tachs.begin(), tachs.end(),
- [](bool func) { return !func; });
- });
+ return std::any_of(tachs.begin(), tachs.end(),
+ [](bool func) { return !func; });
+ });
return count >= _count;
}
diff --git a/monitor/power_off_rule.hpp b/monitor/power_off_rule.hpp
index ad17870..22e8469 100644
--- a/monitor/power_off_rule.hpp
+++ b/monitor/power_off_rule.hpp
@@ -50,8 +50,8 @@
PowerOffRule(PowerRuleState validState,
std::unique_ptr<PowerOffCause> cause,
std::unique_ptr<PowerOffAction> action) :
- _validState(validState),
- _cause(std::move(cause)), _action(std::move(action))
+ _validState(validState), _cause(std::move(cause)),
+ _action(std::move(action))
{}
/**
diff --git a/monitor/system.cpp b/monitor/system.cpp
index 5c2ed4e..476a7f1 100644
--- a/monitor/system.cpp
+++ b/monitor/system.cpp
@@ -50,8 +50,7 @@
System::System(Mode mode, sdbusplus::bus_t& bus,
const sdeventplus::Event& event) :
- _mode(mode),
- _bus(bus), _event(event),
+ _mode(mode), _bus(bus), _event(event),
#ifdef MONITOR_USE_HOST_STATE
_powerState(std::make_unique<HostPowerState>(
#else
@@ -120,8 +119,8 @@
// off here.
std::for_each(_powerOffRules.begin(), _powerOffRules.end(),
[this](auto& rule) {
- rule->check(PowerRuleState::runtime, _fanHealth);
- });
+ rule->check(PowerRuleState::runtime, _fanHealth);
+ });
}
subscribeSensorsToServices();
@@ -329,8 +328,8 @@
sensorStatus.push_back(sensor->functional());
}
- _fanHealth[fan.getName()] = std::make_tuple(fan.present(),
- std::move(sensorStatus));
+ _fanHealth[fan.getName()] =
+ std::make_tuple(fan.present(), std::move(sensorStatus));
}
void System::fanStatusChange(const Fan& fan, bool skipRulesCheck)
@@ -341,8 +340,8 @@
{
std::for_each(_powerOffRules.begin(), _powerOffRules.end(),
[this](auto& rule) {
- rule->check(PowerRuleState::runtime, _fanHealth);
- });
+ rule->check(PowerRuleState::runtime, _fanHealth);
+ });
}
}
@@ -378,18 +377,18 @@
// If no fan has its sensors on D-Bus, then there is a problem
// with the fan controller. Log an error and shut down.
if (std::all_of(_fans.begin(), _fans.end(), [](const auto& fan) {
- return fan->numSensorsOnDBusAtPowerOn() == 0;
- }))
+ return fan->numSensorsOnDBusAtPowerOn() == 0;
+ }))
{
#if DELAY_HOST_CONTROL > 0
sleep(DELAY_HOST_CONTROL);
std::for_each(_fans.begin(), _fans.end(),
[powerStateOn](auto& fan) {
- fan->powerStateChanged(powerStateOn);
- });
+ fan->powerStateChanged(powerStateOn);
+ });
if (std::all_of(_fans.begin(), _fans.end(), [](const auto& fan) {
- return fan->numSensorsOnDBusAtPowerOn() == 0;
- }))
+ return fan->numSensorsOnDBusAtPowerOn() == 0;
+ }))
{
handleOfflineFanController();
return;
@@ -407,12 +406,12 @@
std::for_each(_powerOffRules.begin(), _powerOffRules.end(),
[this](auto& rule) {
- rule->check(PowerRuleState::atPgood, _fanHealth);
- });
+ rule->check(PowerRuleState::atPgood, _fanHealth);
+ });
std::for_each(_powerOffRules.begin(), _powerOffRules.end(),
[this](auto& rule) {
- rule->check(PowerRuleState::runtime, _fanHealth);
- });
+ rule->check(PowerRuleState::runtime, _fanHealth);
+ });
}
else
{
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 1d92231..68c58a2 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -60,8 +60,8 @@
{
try
{
- value = util::SDBusPlus::getProperty<T>(bus, path, interface,
- propertyName);
+ value =
+ util::SDBusPlus::getProperty<T>(bus, path, interface, propertyName);
}
catch (const std::exception& e)
{
@@ -76,8 +76,7 @@
size_t method, size_t threshold, bool ignoreAboveMax,
size_t timeout, const std::optional<size_t>& errorDelay,
size_t countInterval, const sdeventplus::Event& event) :
- _bus(bus),
- _fan(fan), _name(FAN_SENSOR_PATH + id),
+ _bus(bus), _fan(fan), _name(FAN_SENSOR_PATH + id),
_invName(fs::path(fan.getName()) / id), _hasTarget(hasTarget),
_funcDelay(funcDelay), _interface(interface), _path(path), _factor(factor),
_offset(offset), _method(method), _threshold(threshold),
@@ -190,8 +189,8 @@
{
if (path)
{
- return sdbusplus::bus::match::rules::propertiesChanged(path.value(),
- interface);
+ return sdbusplus::bus::match::rules::propertiesChanged(
+ path.value(), interface);
}
return sdbusplus::bus::match::rules::propertiesChanged(_name, interface);
}
@@ -205,9 +204,8 @@
return _tachTarget;
}
-std::pair<uint64_t, std::optional<uint64_t>>
- TachSensor::getRange(const size_t lowerDeviation,
- const size_t upperDeviation) const
+std::pair<uint64_t, std::optional<uint64_t>> TachSensor::getRange(
+ const size_t lowerDeviation, const size_t upperDeviation) const
{
// Determine min/max range applying the deviation
uint64_t min = getTarget() * (100 - lowerDeviation) / 100;
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index 1468ab1..74eede6 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -125,10 +125,9 @@
* @param[out] value - the value to store the property value in
*/
template <typename T>
- static void readPropertyFromMessage(sdbusplus::message_t& msg,
- const std::string& interface,
- const std::string& propertyName,
- T& value)
+ static void readPropertyFromMessage(
+ sdbusplus::message_t& msg, const std::string& interface,
+ const std::string& propertyName, T& value)
{
std::string sensor;
std::map<std::string, std::variant<T>> data;
@@ -350,9 +349,8 @@
*
* @return pair - Min/Max(optional) range of speeds allowed
*/
- std::pair<uint64_t, std::optional<uint64_t>>
- getRange(const size_t lowerDeviation,
- const size_t upperDeviation) const;
+ std::pair<uint64_t, std::optional<uint64_t>> getRange(
+ const size_t lowerDeviation, const size_t upperDeviation) const;
/**
* @brief Processes the current state of the sensor
diff --git a/monitor/trust_group.hpp b/monitor/trust_group.hpp
index 3e73525..001076b 100644
--- a/monitor/trust_group.hpp
+++ b/monitor/trust_group.hpp
@@ -66,11 +66,11 @@
*/
void registerSensor(std::shared_ptr<monitor::TachSensor>& sensor)
{
- auto found = std::find_if(_names.begin(), _names.end(),
- [&sensor](const auto& name) {
- return monitor::FAN_SENSOR_PATH + std::get<sensorName>(name) ==
- sensor->name();
- });
+ auto found = std::find_if(
+ _names.begin(), _names.end(), [&sensor](const auto& name) {
+ return monitor::FAN_SENSOR_PATH + std::get<sensorName>(name) ==
+ sensor->name();
+ });
if (found != _names.end())
{
@@ -90,8 +90,8 @@
{
return (std::find_if(_sensors.begin(), _sensors.end(),
[&sensor](const auto& s) {
- return sensor.name() == s.sensor->name();
- }) != _sensors.end());
+ return sensor.name() == s.sensor->name();
+ }) != _sensors.end());
}
/**
diff --git a/power_state.hpp b/power_state.hpp
index c428a39..c5b0f0d 100644
--- a/power_state.hpp
+++ b/power_state.hpp
@@ -143,10 +143,11 @@
PGoodState& operator=(PGoodState&&) = delete;
PGoodState() :
- PowerState(), _match(_bus,
- sdbusplus::bus::match::rules::propertiesChanged(
- _pgoodPath, _pgoodInterface),
- [this](auto& msg) { this->pgoodChanged(msg); })
+ PowerState(),
+ _match(_bus,
+ sdbusplus::bus::match::rules::propertiesChanged(_pgoodPath,
+ _pgoodInterface),
+ [this](auto& msg) { this->pgoodChanged(msg); })
{
readPGood();
}
diff --git a/presence/anyof.cpp b/presence/anyof.cpp
index 6b9403a..635e6a6 100644
--- a/presence/anyof.cpp
+++ b/presence/anyof.cpp
@@ -36,8 +36,8 @@
AnyOf::AnyOf(const Fan& fan,
const std::vector<std::reference_wrapper<PresenceSensor>>& s,
std::unique_ptr<EEPROMDevice> e) :
- RedundancyPolicy(fan, std::move(e)),
- state(), _powerState(getPowerStateObject()),
+ RedundancyPolicy(fan, std::move(e)), state(),
+ _powerState(getPowerStateObject()),
_powerOnDelayTimer(sdeventplus::Event::get_default(),
std::bind(&AnyOf::delayedAfterPowerOn, this)),
_powerOn(false)
@@ -62,10 +62,10 @@
void AnyOf::stateChanged(bool present, PresenceSensor& sensor)
{
// Find the sensor that changed state.
- auto sit = std::find_if(state.begin(), state.end(),
- [&sensor](const auto& s) {
- return std::get<sensorPos>(s).get() == sensor;
- });
+ auto sit =
+ std::find_if(state.begin(), state.end(), [&sensor](const auto& s) {
+ return std::get<sensorPos>(s).get() == sensor;
+ });
if (sit != state.end())
{
auto origState =
@@ -139,9 +139,10 @@
// If at least one, but not all, sensors indicate present, then
// tell the not present ones to log a conflict if not already done.
- if (std::any_of(
- state.begin(), state.end(),
- [this](const auto& s) { return std::get<presentPos>(s); }) &&
+ if (std::any_of(state.begin(), state.end(),
+ [this](const auto& s) {
+ return std::get<presentPos>(s);
+ }) &&
!std::all_of(state.begin(), state.end(),
[this](const auto& s) { return std::get<presentPos>(s); }))
{
diff --git a/presence/eeprom_device.hpp b/presence/eeprom_device.hpp
index 883cc17..a193471 100644
--- a/presence/eeprom_device.hpp
+++ b/presence/eeprom_device.hpp
@@ -41,8 +41,8 @@
*/
EEPROMDevice(const std::string& address, const std::string& driver,
size_t bindDelayInMS) :
- address(address),
- path(baseDriverPath / driver), bindDelay(bindDelayInMS),
+ address(address), path(baseDriverPath / driver),
+ bindDelay(bindDelayInMS),
timer(SDEventPlus::getEvent(),
std::bind(std::mem_fn(&EEPROMDevice::bindTimerExpired), this))
{}
diff --git a/presence/error_reporter.cpp b/presence/error_reporter.cpp
index b095717..927ca2f 100644
--- a/presence/error_reporter.cpp
+++ b/presence/error_reporter.cpp
@@ -47,8 +47,7 @@
sdbusplus::bus_t& bus,
const std::vector<
std::tuple<Fan, std::vector<std::unique_ptr<PresenceSensor>>>>& fans) :
- _bus(bus),
- _event(sdeventplus::Event::get_default()),
+ _bus(bus), _event(sdeventplus::Event::get_default()),
_powerState(getPowerStateObject())
{
_powerState->addCallback("errorReporter",
@@ -212,9 +211,10 @@
}
}
- std::for_each(
- _fanStates.begin(), _fanStates.end(),
- [this](const auto& fanState) { this->checkFan(fanState.first); });
+ std::for_each(_fanStates.begin(), _fanStates.end(),
+ [this](const auto& fanState) {
+ this->checkFan(fanState.first);
+ });
}
} // namespace phosphor::fan::presence
diff --git a/presence/error_reporter.hpp b/presence/error_reporter.hpp
index d6bc109..ef1111b 100644
--- a/presence/error_reporter.hpp
+++ b/presence/error_reporter.hpp
@@ -43,9 +43,8 @@
*/
ErrorReporter(
sdbusplus::bus_t& bus,
- const std::vector<
- std::tuple<Fan, std::vector<std::unique_ptr<PresenceSensor>>>>&
- fans);
+ const std::vector<std::tuple<
+ Fan, std::vector<std::unique_ptr<PresenceSensor>>>>& fans);
private:
/**
diff --git a/presence/fallback.cpp b/presence/fallback.cpp
index f301ac1..b3fc54a 100644
--- a/presence/fallback.cpp
+++ b/presence/fallback.cpp
@@ -79,8 +79,9 @@
{
// Find the first sensor that says the fan is present
// and set it as the active sensor.
- activeSensor = std::find_if(sensors.begin(), sensors.end(),
- [](auto& s) { return s.get().present(); });
+ activeSensor = std::find_if(sensors.begin(), sensors.end(), [](auto& s) {
+ return s.get().present();
+ });
if (activeSensor == sensors.end())
{
// The first sensor is working or all sensors
diff --git a/presence/fallback.hpp b/presence/fallback.hpp
index e6a1685..b9e2cbd 100644
--- a/presence/fallback.hpp
+++ b/presence/fallback.hpp
@@ -44,8 +44,7 @@
Fallback(const Fan& fan,
const std::vector<std::reference_wrapper<PresenceSensor>>& s,
std::unique_ptr<EEPROMDevice> e) :
- RedundancyPolicy(fan, std::move(e)),
- sensors(s)
+ RedundancyPolicy(fan, std::move(e)), sensors(s)
{
activeSensor = sensors.begin();
}
diff --git a/presence/gpio.cpp b/presence/gpio.cpp
index ceba1c6..0bd5b6f 100644
--- a/presence/gpio.cpp
+++ b/presence/gpio.cpp
@@ -41,8 +41,7 @@
Gpio::Gpio(const std::string& physDevice, const std::string& device,
unsigned int physPin) :
- currentState(false),
- evdevfd(open(device.c_str(), O_RDONLY | O_NONBLOCK)),
+ currentState(false), evdevfd(open(device.c_str(), O_RDONLY | O_NONBLOCK)),
evdev(evdevpp::evdev::newFromFD(evdevfd())), phys(physDevice), pin(physPin)
{}
diff --git a/presence/json_parser.cpp b/presence/json_parser.cpp
index ea1d496..d5705ef 100644
--- a/presence/json_parser.cpp
+++ b/presence/json_parser.cpp
@@ -190,14 +190,14 @@
eeprom["bind_delay_ms"].get<size_t>());
}
- auto fan = std::make_tuple(member["name"], member["path"],
- timeUntilError);
+ auto fan =
+ std::make_tuple(member["name"], member["path"], timeUntilError);
// Create a fan object
fans.emplace_back(std::make_tuple(fan, std::move(sensors)));
// Add fan presence policy
- auto policy = getPolicy(member["rpolicy"], fans.back(),
- std::move(eepromDevice));
+ auto policy =
+ getPolicy(member["rpolicy"], fans.back(), std::move(eepromDevice));
if (policy)
{
policies.emplace_back(std::move(policy));
@@ -213,9 +213,9 @@
// Create the error reporter class if necessary
if (std::any_of(_fans.begin(), _fans.end(), [](const auto& fan) {
- return std::get<std::optional<size_t>>(std::get<Fan>(fan)) !=
- std::nullopt;
- }))
+ return std::get<std::optional<size_t>>(std::get<Fan>(fan)) !=
+ std::nullopt;
+ }))
{
_reporter = std::make_unique<ErrorReporter>(_bus, _fans);
}
@@ -278,8 +278,8 @@
sensors.emplace_back(sensor.get<std::string>());
}
- return std::make_unique<PolicyAccess<Tach, JsonConfig>>(fanIndex,
- std::move(sensors));
+ return std::make_unique<PolicyAccess<Tach, JsonConfig>>(
+ fanIndex, std::move(sensors));
}
// Get a constructed presence sensor for fan presence detection by gpio
@@ -363,9 +363,8 @@
}
// Get a `Fallback` redundancy policy for the fan
-std::unique_ptr<RedundancyPolicy>
- getFallback(const fanPolicy& fan,
- std::unique_ptr<EEPROMDevice> eepromDevice)
+std::unique_ptr<RedundancyPolicy> getFallback(
+ const fanPolicy& fan, std::unique_ptr<EEPROMDevice> eepromDevice)
{
std::vector<std::reference_wrapper<PresenceSensor>> pSensors;
for (auto& fanSensor : std::get<fanPolicySensorListPos>(fan))
diff --git a/presence/json_parser.hpp b/presence/json_parser.hpp
index 9fe5645..1e23380 100644
--- a/presence/json_parser.hpp
+++ b/presence/json_parser.hpp
@@ -185,9 +185,8 @@
*
* @return - A `Fallback` redundancy policy
*/
-std::unique_ptr<RedundancyPolicy>
- getFallback(const fanPolicy& fan,
- std::unique_ptr<EEPROMDevice> eepromDevice);
+std::unique_ptr<RedundancyPolicy> getFallback(
+ const fanPolicy& fan, std::unique_ptr<EEPROMDevice> eepromDevice);
} // namespace rpolicy
diff --git a/presence/rpolicy.hpp b/presence/rpolicy.hpp
index e190029..259a31b 100644
--- a/presence/rpolicy.hpp
+++ b/presence/rpolicy.hpp
@@ -40,8 +40,7 @@
*/
explicit RedundancyPolicy(const Fan& f,
std::unique_ptr<EEPROMDevice> eeprom) :
- fan(f),
- eepromDevice(std::move(eeprom))
+ fan(f), eepromDevice(std::move(eeprom))
{}
/**
diff --git a/presence/tach.hpp b/presence/tach.hpp
index db8efa2..d45d595 100644
--- a/presence/tach.hpp
+++ b/presence/tach.hpp
@@ -90,9 +90,8 @@
* @param[in] sensor - The sensor that changed.
* @param[in] props - The properties that changed.
*/
- void
- propertiesChanged(size_t sensor,
- const phosphor::fan::util::Properties<double>& props);
+ void propertiesChanged(
+ size_t sensor, const phosphor::fan::util::Properties<double>& props);
/**
* @brief Properties changed handler for tach sensor updates.
diff --git a/sdbusplus.hpp b/sdbusplus.hpp
index 9627e40..4068923 100644
--- a/sdbusplus.hpp
+++ b/sdbusplus.hpp
@@ -167,10 +167,9 @@
/** @brief Invoke a method and read the response. */
template <typename Ret, typename... Args>
- static auto callMethodAndRead(const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method, Args&&... args)
+ static auto callMethodAndRead(
+ const std::string& busName, const std::string& path,
+ const std::string& interface, const std::string& method, Args&&... args)
{
return callMethodAndRead<Ret>(getBus(), busName, path, interface,
method, std::forward<Args>(args)...);
@@ -189,11 +188,11 @@
using Objects = std::map<Path, std::map<Serv, Intfs>>;
Intfs intfs = {interface};
- return callMethodAndRead<Objects>(bus,
- "xyz.openbmc_project.ObjectMapper"s,
- "/xyz/openbmc_project/object_mapper"s,
- "xyz.openbmc_project.ObjectMapper"s,
- "GetSubTree"s, path, depth, intfs);
+ return callMethodAndRead<Objects>(
+ bus, "xyz.openbmc_project.ObjectMapper"s,
+ "/xyz/openbmc_project/object_mapper"s,
+ "xyz.openbmc_project.ObjectMapper"s, "GetSubTree"s, path, depth,
+ intfs);
}
/** @brief Get subtree from the mapper without checking response,
@@ -210,11 +209,11 @@
using Intfs = std::vector<Intf>;
using Objects = std::map<Path, std::map<Serv, Intfs>>;
- return callMethodAndRead<Objects>(bus,
- "xyz.openbmc_project.ObjectMapper"s,
- "/xyz/openbmc_project/object_mapper"s,
- "xyz.openbmc_project.ObjectMapper"s,
- "GetSubTree"s, path, depth, intfs);
+ return callMethodAndRead<Objects>(
+ bus, "xyz.openbmc_project.ObjectMapper"s,
+ "/xyz/openbmc_project/object_mapper"s,
+ "xyz.openbmc_project.ObjectMapper"s, "GetSubTree"s, path, depth,
+ intfs);
}
/** @brief Get subtree from the mapper. */
@@ -344,9 +343,9 @@
using namespace std::literals::string_literals;
auto service = getService(bus, path, interface);
- auto msg = callMethod(bus, service, path,
- "org.freedesktop.DBus.Properties"s, "Get"s,
- interface, property);
+ auto msg =
+ callMethod(bus, service, path, "org.freedesktop.DBus.Properties"s,
+ "Get"s, interface, property);
if (msg.is_method_error())
{
throw DBusPropertyError{"DBus get property failed", service, path,
@@ -368,17 +367,16 @@
/** @brief Get a property variant with mapper lookup. */
template <typename Variant>
- static auto getPropertyVariant(sdbusplus::bus_t& bus,
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+ static auto getPropertyVariant(
+ sdbusplus::bus_t& bus, const std::string& path,
+ const std::string& interface, const std::string& property)
{
using namespace std::literals::string_literals;
auto service = getService(bus, path, interface);
- auto msg = callMethod(bus, service, path,
- "org.freedesktop.DBus.Properties"s, "Get"s,
- interface, property);
+ auto msg =
+ callMethod(bus, service, path, "org.freedesktop.DBus.Properties"s,
+ "Get"s, interface, property);
if (msg.is_method_error())
{
throw DBusPropertyError{"DBus get property variant failed", service,
@@ -400,11 +398,10 @@
/** @brief Invoke a method and return without checking for error. */
template <typename... Args>
- static auto callMethodAndReturn(sdbusplus::bus_t& bus,
- const std::string& busName,
- const std::string& path,
- const std::string& interface,
- const std::string& method, Args&&... args)
+ static auto callMethodAndReturn(
+ sdbusplus::bus_t& bus, const std::string& busName,
+ const std::string& path, const std::string& interface,
+ const std::string& method, Args&&... args)
{
auto reqMsg = bus.new_method_call(busName.c_str(), path.c_str(),
interface.c_str(), method.c_str());
@@ -448,11 +445,10 @@
/** @brief Get a property variant without mapper lookup. */
template <typename Variant>
- static auto getPropertyVariant(sdbusplus::bus_t& bus,
- const std::string& service,
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+ static auto getPropertyVariant(
+ sdbusplus::bus_t& bus, const std::string& service,
+ const std::string& path, const std::string& interface,
+ const std::string& property)
{
using namespace std::literals::string_literals;
@@ -471,10 +467,9 @@
/** @brief Get a property variant without mapper lookup. */
template <typename Variant>
- static auto getPropertyVariant(const std::string& service,
- const std::string& path,
- const std::string& interface,
- const std::string& property)
+ static auto getPropertyVariant(
+ const std::string& service, const std::string& path,
+ const std::string& interface, const std::string& property)
{
return getPropertyVariant<Variant>(getBus(), service, path, interface,
property);
@@ -544,10 +539,9 @@
/** @brief Invoke method with mapper lookup. */
template <typename... Args>
- static auto lookupAndCallMethod(sdbusplus::bus_t& bus,
- const std::string& path,
- const std::string& interface,
- const std::string& method, Args&&... args)
+ static auto lookupAndCallMethod(
+ sdbusplus::bus_t& bus, const std::string& path,
+ const std::string& interface, const std::string& method, Args&&... args)
{
return callMethod(bus, getService(bus, path, interface), path,
interface, method, std::forward<Args>(args)...);
@@ -565,10 +559,9 @@
/** @brief Invoke method and read with mapper lookup. */
template <typename Ret, typename... Args>
- static auto
- lookupCallMethodAndRead(sdbusplus::bus_t& bus, const std::string& path,
- const std::string& interface,
- const std::string& method, Args&&... args)
+ static auto lookupCallMethodAndRead(
+ sdbusplus::bus_t& bus, const std::string& path,
+ const std::string& interface, const std::string& method, Args&&... args)
{
return callMethodAndRead(bus, getService(bus, path, interface), path,
interface, method,
@@ -577,10 +570,9 @@
/** @brief Invoke method and read with mapper lookup. */
template <typename Ret, typename... Args>
- static auto lookupCallMethodAndRead(const std::string& path,
- const std::string& interface,
- const std::string& method,
- Args&&... args)
+ static auto lookupCallMethodAndRead(
+ const std::string& path, const std::string& interface,
+ const std::string& method, Args&&... args)
{
return lookupCallMethodAndRead<Ret>(getBus(), path, interface, method,
std::forward<Args>(args)...);
diff --git a/sensor-monitor/shutdown_alarm_monitor.cpp b/sensor-monitor/shutdown_alarm_monitor.cpp
index 214e3a3..9b51a8b 100644
--- a/sensor-monitor/shutdown_alarm_monitor.cpp
+++ b/sensor-monitor/shutdown_alarm_monitor.cpp
@@ -88,8 +88,7 @@
ShutdownAlarmMonitor::ShutdownAlarmMonitor(
sdbusplus::bus_t& bus, sdeventplus::Event& event,
std::shared_ptr<PowerState> powerState) :
- bus(bus),
- event(event), _powerState(std::move(powerState)),
+ bus(bus), event(event), _powerState(std::move(powerState)),
hardShutdownMatch(bus,
"type='signal',member='PropertiesChanged',"
"path_namespace='/xyz/openbmc_project/sensors',"
@@ -133,13 +132,14 @@
auto shutdownType2 = shutdownType;
- std::for_each(paths.begin(), paths.end(),
- [this, shutdownType2](const auto& path) {
- alarms.emplace(AlarmKey{path, shutdownType2, AlarmType::high},
- nullptr);
- alarms.emplace(AlarmKey{path, shutdownType2, AlarmType::low},
- nullptr);
- });
+ std::for_each(
+ paths.begin(), paths.end(),
+ [this, shutdownType2](const auto& path) {
+ alarms.emplace(AlarmKey{path, shutdownType2, AlarmType::high},
+ nullptr);
+ alarms.emplace(AlarmKey{path, shutdownType2, AlarmType::low},
+ nullptr);
+ });
}
}
diff --git a/sensor-monitor/threshold_alarm_logger.cpp b/sensor-monitor/threshold_alarm_logger.cpp
index 29cd229..6d78c0a 100644
--- a/sensor-monitor/threshold_alarm_logger.cpp
+++ b/sensor-monitor/threshold_alarm_logger.cpp
@@ -89,8 +89,7 @@
ThresholdAlarmLogger::ThresholdAlarmLogger(
sdbusplus::bus_t& bus, sdeventplus::Event& event,
std::shared_ptr<PowerState> powerState) :
- bus(bus),
- event(event), _powerState(std::move(powerState)),
+ bus(bus), event(event), _powerState(std::move(powerState)),
warningMatch(bus,
"type='signal',member='PropertiesChanged',"
"path_namespace='/xyz/openbmc_project/sensors',"
@@ -128,17 +127,20 @@
this, std::placeholders::_1));
// check for any currently asserted threshold alarms
- std::for_each(thresholdData.begin(), thresholdData.end(),
- [this](const auto& thresholdInterface) {
- const auto& interface = thresholdInterface.first;
- auto objects = SDBusPlus::getSubTreeRaw(this->bus, "/", interface, 0);
- std::for_each(objects.begin(), objects.end(),
- [interface, this](const auto& object) {
- const auto& path = object.first;
- const auto& service = object.second.begin()->first;
- checkThresholds(interface, path, service);
+ std::for_each(
+ thresholdData.begin(), thresholdData.end(),
+ [this](const auto& thresholdInterface) {
+ const auto& interface = thresholdInterface.first;
+ auto objects =
+ SDBusPlus::getSubTreeRaw(this->bus, "/", interface, 0);
+ std::for_each(objects.begin(), objects.end(),
+ [interface, this](const auto& object) {
+ const auto& path = object.first;
+ const auto& service =
+ object.second.begin()->first;
+ checkThresholds(interface, path, service);
+ });
});
- });
}
void ThresholdAlarmLogger::propertiesChanged(sdbusplus::message_t& msg)
@@ -262,10 +264,9 @@
}
}
-void ThresholdAlarmLogger::createEventLog(const std::string& sensorPath,
- const std::string& interface,
- const std::string& alarmProperty,
- bool alarmValue)
+void ThresholdAlarmLogger::createEventLog(
+ const std::string& sensorPath, const std::string& interface,
+ const std::string& alarmProperty, bool alarmValue)
{
std::map<std::string, std::string> ad;
@@ -332,8 +333,8 @@
try
{
- auto thresholdValue = SDBusPlus::getProperty<double>(bus, sensorPath,
- interface, name);
+ auto thresholdValue =
+ SDBusPlus::getProperty<double>(bus, sensorPath, interface, name);
ad.emplace("THRESHOLD_VALUE", std::to_string(thresholdValue));