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: Ic16d6d63213bbdd91fcb8f5aa986b66865efda2f
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/bmc_state_manager.hpp b/bmc_state_manager.hpp
index d0b37a2..50d25f1 100644
--- a/bmc_state_manager.hpp
+++ b/bmc_state_manager.hpp
@@ -51,22 +51,22 @@
"/org/freedesktop/systemd1/unit/time_2dsync_2etarget",
"org.freedesktop.systemd1.Unit"),
[this](sdbusplus::message_t& m) {
- std::string interface;
- std::unordered_map<std::string, std::variant<std::string>>
- propertyChanged;
- m.read(interface, propertyChanged);
+ std::string interface;
+ std::unordered_map<std::string, std::variant<std::string>>
+ propertyChanged;
+ m.read(interface, propertyChanged);
- for (const auto& [key, value] : propertyChanged)
- {
- if (key == "ActiveState" &&
- std::holds_alternative<std::string>(value) &&
- std::get<std::string>(value) == "active")
- {
- updateLastRebootTime();
- timeSyncSignal.reset();
- }
- }
- }))
+ for (const auto& [key, value] : propertyChanged)
+ {
+ if (key == "ActiveState" &&
+ std::holds_alternative<std::string>(value) &&
+ std::get<std::string>(value) == "active")
+ {
+ updateLastRebootTime();
+ timeSyncSignal.reset();
+ }
+ }
+ }))
{
utils::subscribeToSystemdSignals(bus);
discoverInitialState();
diff --git a/chassis_state_manager_main.cpp b/chassis_state_manager_main.cpp
index 35f8801..377786e 100644
--- a/chassis_state_manager_main.cpp
+++ b/chassis_state_manager_main.cpp
@@ -41,8 +41,8 @@
auto bus = sdbusplus::bus::new_default();
- auto chassisBusName = std::string{CHASSIS_BUSNAME} +
- std::to_string(chassisId);
+ auto chassisBusName =
+ std::string{CHASSIS_BUSNAME} + std::to_string(chassisId);
auto objPathInst = std::string{CHASSIS_OBJPATH} + std::to_string(chassisId);
if (chassisId == 0)
diff --git a/discover_system_state.cpp b/discover_system_state.cpp
index 53a414f..c84b511 100644
--- a/discover_system_state.cpp
+++ b/discover_system_state.cpp
@@ -63,9 +63,9 @@
}
using Host = sdbusplus::client::xyz::openbmc_project::state::Host<>;
- std::string hostPath = std::string(Host::namespace_path::value) + "/" +
- std::string(Host::namespace_path::host) +
- std::to_string(hostId);
+ std::string hostPath =
+ std::string(Host::namespace_path::value) + "/" +
+ std::string(Host::namespace_path::host) + std::to_string(hostId);
auto bus = sdbusplus::bus::new_default();
diff --git a/host_condition_gpio/host_condition.hpp b/host_condition_gpio/host_condition.hpp
index 6e260b8..a8895f5 100644
--- a/host_condition_gpio/host_condition.hpp
+++ b/host_condition_gpio/host_condition.hpp
@@ -26,8 +26,7 @@
Host(sdbusplus::bus_t& bus, const std::string& path,
const std::string& hostId) :
- HostIntf(bus, path.c_str()),
- lineName("host" + hostId)
+ HostIntf(bus, path.c_str()), lineName("host" + hostId)
{
scanGpioPin();
};
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index 27d3e27..3118b4a 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -117,14 +117,12 @@
{Transition::GracefulWarmReboot,
std::format("obmc-host-warm-reboot@{}.target", id)},
{Transition::ForceWarmReboot,
- std::format("obmc-host-force-warm-reboot@{}.target", id)}
- };
+ std::format("obmc-host-force-warm-reboot@{}.target", id)}};
#else
{Transition::GracefulWarmReboot,
std::format("obmc-host-reboot@{}.target", id)},
{Transition::ForceWarmReboot,
- std::format("obmc-host-reboot@{}.target", id)}
- };
+ std::format("obmc-host-reboot@{}.target", id)}};
#endif
hostCrashTarget = std::format("obmc-host-crash@{}.target", id);
}
diff --git a/scheduled_host_transition.cpp b/scheduled_host_transition.cpp
index 01e698e..eb5975c 100644
--- a/scheduled_host_transition.cpp
+++ b/scheduled_host_transition.cpp
@@ -237,9 +237,8 @@
}
}
-int ScheduledHostTransition::onTimeChange(sd_event_source* /* es */, int fd,
- uint32_t /* revents */,
- void* userdata)
+int ScheduledHostTransition::onTimeChange(
+ sd_event_source* /* es */, int fd, uint32_t /* revents */, void* userdata)
{
auto* schedHostTran = static_cast<ScheduledHostTransition*>(userdata);
diff --git a/scheduled_host_transition.hpp b/scheduled_host_transition.hpp
index 2fe3e36..1966f63 100644
--- a/scheduled_host_transition.hpp
+++ b/scheduled_host_transition.hpp
@@ -107,11 +107,11 @@
/** @brief The deleter of sd_event_source */
std::function<void(sd_event_source*)> sdEventSourceDeleter =
[](sd_event_source* p) {
- if (p != nullptr)
- {
- sd_event_source_unref(p);
- }
- };
+ if (p != nullptr)
+ {
+ sd_event_source_unref(p);
+ }
+ };
using SdEventSource =
std::unique_ptr<sd_event_source, decltype(sdEventSourceDeleter)>;
diff --git a/secure_boot_check.cpp b/secure_boot_check.cpp
index ce3dfe0..4de841e 100644
--- a/secure_boot_check.cpp
+++ b/secure_boot_check.cpp
@@ -122,8 +122,8 @@
int secureBootVal = -1;
int abrImage = -1;
- dbgFile.exceptions(std::ifstream::failbit | std::ifstream::badbit |
- std::ifstream::eofbit);
+ dbgFile.exceptions(
+ std::ifstream::failbit | std::ifstream::badbit | std::ifstream::eofbit);
if (std::filesystem::exists(SYSFS_SECURE_BOOT_PATH))
{
diff --git a/settings.cpp b/settings.cpp
index a334a84..0445092 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -100,9 +100,9 @@
Service Objects::service(const Path& path, const Interface& interface) const
{
using Interfaces = std::vector<Interface>;
- auto mapperCall = bus.new_method_call(ObjectMapper::default_service,
- ObjectMapper::instance_path,
- ObjectMapper::interface, "GetObject");
+ auto mapperCall = bus.new_method_call(
+ ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface, "GetObject");
mapperCall.append(path);
mapperCall.append(Interfaces({interface}));
diff --git a/systemd_target_monitor.cpp b/systemd_target_monitor.cpp
index 44841c8..7ae8137 100644
--- a/systemd_target_monitor.cpp
+++ b/systemd_target_monitor.cpp
@@ -82,8 +82,8 @@
dump_targets(targetData);
}
- phosphor::state::manager::SystemdTargetLogging targetMon(targetData,
- serviceData, bus);
+ phosphor::state::manager::SystemdTargetLogging targetMon(
+ targetData, serviceData, bus);
// Subscribe to systemd D-bus signals indicating target completions
targetMon.subscribeToSystemdSignals();
diff --git a/systemd_target_parser.cpp b/systemd_target_parser.cpp
index 9482c65..2a9727a 100644
--- a/systemd_target_parser.cpp
+++ b/systemd_target_parser.cpp
@@ -19,8 +19,8 @@
}
}
// See if default was in the errors to monitor, if so replace with defaults
- auto errorItr = std::find(errorsToMonitor.begin(), errorsToMonitor.end(),
- "default");
+ auto errorItr =
+ std::find(errorsToMonitor.begin(), errorsToMonitor.end(), "default");
if (errorItr != errorsToMonitor.end())
{
// Verify default is the only entry
diff --git a/systemd_target_signal.cpp b/systemd_target_signal.cpp
index 7698c0e..68933c0 100644
--- a/systemd_target_signal.cpp
+++ b/systemd_target_signal.cpp
@@ -54,9 +54,9 @@
const std::string& result,
const std::string& unit)
{
- auto method = this->bus.new_method_call(LoggingCreate::default_service,
- LoggingCreate::instance_path,
- LoggingCreate::interface, "Create");
+ auto method = this->bus.new_method_call(
+ LoggingCreate::default_service, LoggingCreate::instance_path,
+ LoggingCreate::interface, "Create");
// Signature is ssa{ss}
method.append(
errorLog, LoggingEntry::Level::Critical,
@@ -83,8 +83,8 @@
{
// Check if its result matches any of our monitored errors
if (std::find(targetEntry->second.errorsToMonitor.begin(),
- targetEntry->second.errorsToMonitor.end(),
- result) != targetEntry->second.errorsToMonitor.end())
+ targetEntry->second.errorsToMonitor.end(), result) !=
+ targetEntry->second.errorsToMonitor.end())
{
info(
"Monitored systemd unit has hit an error, unit:{UNIT}, result:{RESULT}",
diff --git a/systemd_target_signal.hpp b/systemd_target_signal.hpp
index 4839d55..a273a79 100644
--- a/systemd_target_signal.hpp
+++ b/systemd_target_signal.hpp
@@ -31,8 +31,7 @@
SystemdTargetLogging(const TargetErrorData& targetData,
const ServiceMonitorData& serviceData,
sdbusplus::bus_t& bus) :
- targetData(targetData),
- serviceData(serviceData), bus(bus),
+ targetData(targetData), serviceData(serviceData), bus(bus),
systemdJobRemovedSignal(
bus,
sdbusplus::bus::match::rules::type::signal() +
diff --git a/test/systemd_signal.cpp b/test/systemd_signal.cpp
index 630d57c..917a4e0 100644
--- a/test/systemd_signal.cpp
+++ b/test/systemd_signal.cpp
@@ -28,8 +28,8 @@
auto event = sdeventplus::Event::get_default();
bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
- phosphor::state::manager::SystemdTargetLogging targetMon(targetData,
- serviceData, bus);
+ phosphor::state::manager::SystemdTargetLogging targetMon(
+ targetData, serviceData, bus);
std::string invalidUnit = "invalid_unit";
std::string validError = "timeout";
diff --git a/utils.cpp b/utils.cpp
index 8ebe270..26a1e8b 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -209,9 +209,9 @@
sdbusplus::message::object_path(DumpCreate::namespace_path::value) /
DumpCreate::namespace_path::bmc;
- auto method = bus.new_method_call(DumpCreate::default_service,
- dumpPath.str.c_str(),
- DumpCreate::interface, "CreateDump");
+ auto method =
+ bus.new_method_call(DumpCreate::default_service, dumpPath.str.c_str(),
+ DumpCreate::interface, "CreateDump");
method.append(
std::vector<
std::pair<std::string, std::variant<std::string, uint64_t>>>());
@@ -229,8 +229,8 @@
bool checkACLoss(size_t& chassisId)
{
- std::string chassisLostPowerFileFmt = std::format(CHASSIS_LOST_POWER_FILE,
- chassisId);
+ std::string chassisLostPowerFileFmt =
+ std::format(CHASSIS_LOST_POWER_FILE, chassisId);
std::filesystem::path chassisPowerLossFile{chassisLostPowerFileFmt};
return std::filesystem::exists(chassisPowerLossFile);
@@ -242,8 +242,8 @@
auto bmcPath = sdbusplus::message::object_path(BMC::namespace_path::value) /
BMC::namespace_path::bmc;
- auto bmcState = getProperty(bus, bmcPath.str, BMC::interface,
- "CurrentBMCState");
+ auto bmcState =
+ getProperty(bus, bmcPath.str, BMC::interface, "CurrentBMCState");
if (sdbusplus::message::convert_from_string<BMC::BMCState>(bmcState) !=
BMC::BMCState::Ready)