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/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());
}
/**