clang-format: copy latest and re-format
clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.
Change-Id: I152f141a5e8343b92b5ce81d3ca16eec77b5606b
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/control/json/actions/action.hpp b/control/json/actions/action.hpp
index cafa542..dcba6ea 100644
--- a/control/json/actions/action.hpp
+++ b/control/json/actions/action.hpp
@@ -154,11 +154,10 @@
*/
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));
@@ -225,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;
@@ -333,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>(
fmt::format("Action '{}' is not registered", name).c_str(),
entry("AVAILABLE_ACTIONS=%s", acts.c_str()));
diff --git a/control/json/actions/default_floor.cpp b/control/json/actions/default_floor.cpp
index 5ca3c10..f1cc4af 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 eb5600e..099a68b 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 906559b..c947098 100644
--- a/control/json/actions/mapped_floor.cpp
+++ b/control/json/actions/mapped_floor.cpp
@@ -158,7 +158,6 @@
if (!floorEntry.contains("value") ||
!floorEntry.contains("floor"))
{
-
throw ActionParseError{
ActionBase::getName(),
"Missing value or floor entries in "
@@ -234,12 +233,11 @@
{
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);
}
@@ -264,16 +262,16 @@
{
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{fmt::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{fmt::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 ccafdc2..30f91b4 100644
--- a/control/json/actions/missing_owner_target.cpp
+++ b/control/json/actions/missing_owner_target.cpp
@@ -47,8 +47,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 cc08cfa..878dd3f 100644
--- a/control/json/actions/net_target_increase.cpp
+++ b/control/json/actions/net_target_increase.cpp
@@ -44,7 +44,6 @@
void NetTargetIncrease::run(Zone& zone)
{
-
if (!_stateParameter.empty())
{
auto s = Manager::getParameter(_stateParameter);
@@ -59,80 +58,77 @@
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
+ 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))
{
- auto value = Manager::getObjValueVariant(
- member, group.getInterface(), group.getProperty());
- if (std::holds_alternative<int64_t>(value) ||
- std::holds_alternative<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)
{
- // 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)
+ uint64_t incDelta = 0;
+ if (auto dblPtr = std::get_if<double>(&value))
{
- 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);
+ incDelta = static_cast<uint64_t>(
+ (*dblPtr - std::get<double>(_state)) * _delta);
}
- }
- 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
{
- netDelta = std::max(netDelta, _delta);
+ // 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);
}
- }
- 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)
- {
- netDelta = std::max(netDelta, _delta);
- }
- }
- else
- {
- // Unsupported group member type for this action
- log<level::ERR>(
- fmt::format(
- "Action {}: Unsupported group member type "
- "given. [object = {} : {} : {}]",
- ActionBase::getName(), member,
- group.getInterface(), group.getProperty())
- .c_str());
+ netDelta = std::max(netDelta, incDelta);
}
}
- catch (const std::out_of_range& oore)
+ else if (std::holds_alternative<bool>(value))
{
- // Property value not found, netDelta unchanged
+ // Where a group of booleans equal the state(`true` or
+ // `false`) 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)
+ {
+ netDelta = std::max(netDelta, _delta);
+ }
+ }
+ else
+ {
+ // Unsupported group member type for this action
+ log<level::ERR>(
+ fmt::format("Action {}: Unsupported group member type "
+ "given. [object = {} : {} : {}]",
+ ActionBase::getName(), member,
+ group.getInterface(), group.getProperty())
+ .c_str());
+ }
+ }
+ 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/pcie_card_floors.cpp b/control/json/actions/pcie_card_floors.cpp
index 6c465f3..3d242d3 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/pcie_card_floors.hpp b/control/json/actions/pcie_card_floors.hpp
index a662a6d..081f409 100644
--- a/control/json/actions/pcie_card_floors.hpp
+++ b/control/json/actions/pcie_card_floors.hpp
@@ -106,8 +106,7 @@
* to distinguish it from ones under different events and also it just
* makes it uglier in the flight recorder.
*/
- void setEventName(const std::string& /*name*/) override
- {}
+ void setEventName(const std::string& /*name*/) override {}
private:
/**
diff --git a/control/json/actions/set_parameter_from_group_max.cpp b/control/json/actions/set_parameter_from_group_max.cpp
index c7d18a1..b42f582 100644
--- a/control/json/actions/set_parameter_from_group_max.cpp
+++ b/control/json/actions/set_parameter_from_group_max.cpp
@@ -64,19 +64,19 @@
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>(fmt::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>(fmt::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 ef19cdb..79cacf8 100644
--- a/control/json/actions/target_from_group_max.cpp
+++ b/control/json/actions/target_from_group_max.cpp
@@ -138,7 +138,6 @@
{
for (const auto& map : jsonObj.at("map"))
{
-
if (!map.contains("value") || !map.contains("target"))
{
throw ActionParseError{ActionBase::getName(),
@@ -187,18 +186,18 @@
// 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>(fmt::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>(fmt::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 dd5f5ce..e3f3fec 100644
--- a/control/json/actions/timer_based_actions.cpp
+++ b/control/json/actions/timer_based_actions.cpp
@@ -43,10 +43,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);
@@ -62,9 +62,8 @@
const auto& members = group.getMembers();
return std::any_of(members.begin(), members.end(),
[&group](const auto& member) {
- return !Manager::hasOwner(
- member, group.getInterface());
- });
+ return !Manager::hasOwner(member, group.getInterface());
+ });
}))
{
startTimer();
@@ -80,18 +79,16 @@
// 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();
@@ -148,8 +145,8 @@
// Add zone to _actions
std::for_each(_actions.begin(), _actions.end(),
[&zone](std::unique_ptr<ActionBase>& action) {
- action->addZone(zone);
- });
+ action->addZone(zone);
+ });
}
}