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: I8c81e5e5b6bd1ec4bdd52aa9039ef1c4bbef088d
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/bm_instance.cpp b/bm_instance.cpp
index d3fbd8e..dda6e4f 100644
--- a/bm_instance.cpp
+++ b/bm_instance.cpp
@@ -54,8 +54,8 @@
std::string bmInstanceProperty =
handler->getBMInstanceProperty(/*type=*/data[0]);
- const size_t length = sizeof(struct BMInstancePropertyReply) +
- bmInstanceProperty.size();
+ const size_t length =
+ sizeof(struct BMInstancePropertyReply) + bmInstanceProperty.size();
if (length > MAX_IPMI_BUFFER)
{
diff --git a/entity_name.cpp b/entity_name.cpp
index 8d12bfe..454a642 100644
--- a/entity_name.cpp
+++ b/entity_name.cpp
@@ -62,8 +62,8 @@
std::string entityName;
try
{
- entityName = handler->getEntityName(request.entityId,
- request.entityInstance);
+ entityName =
+ handler->getEntityName(request.entityId, request.entityInstance);
}
catch (const IpmiException& e)
{
diff --git a/flash_size.cpp b/flash_size.cpp
index df23f4f..60f9633 100644
--- a/flash_size.cpp
+++ b/flash_size.cpp
@@ -46,9 +46,9 @@
flashSize = htole32(flashSize);
return ::ipmi::responseSuccess(
SysOEMCommands::SysGetFlashSize,
- std::vector<std::uint8_t>((std::uint8_t*)&(flashSize),
- (std::uint8_t*)&(flashSize) +
- sizeof(std::uint32_t)));
+ std::vector<std::uint8_t>(
+ (std::uint8_t*)&(flashSize),
+ (std::uint8_t*)&(flashSize) + sizeof(std::uint32_t)));
}
} // namespace ipmi
} // namespace google
diff --git a/handler.cpp b/handler.cpp
index 8786e29..2483aec 100644
--- a/handler.cpp
+++ b/handler.cpp
@@ -207,10 +207,10 @@
// If value parses as expected, return version.
VersionTuple version = std::make_tuple(0, 0, 0, 0);
- int num_fields = std::sscanf(value.c_str(),
- "%" SCNu8 ".%" SCNu8 ".%" SCNu8 ".%" SCNu8,
- &std::get<0>(version), &std::get<1>(version),
- &std::get<2>(version), &std::get<3>(version));
+ int num_fields =
+ std::sscanf(value.c_str(), "%" SCNu8 ".%" SCNu8 ".%" SCNu8 ".%" SCNu8,
+ &std::get<0>(version), &std::get<1>(version),
+ &std::get<2>(version), &std::get<3>(version));
if (num_fields == 0)
{
stdplus::print(stderr, "Invalid version.\n");
@@ -725,10 +725,10 @@
std::format("{}{}", ACCEL_POWER_PATH_PREFIX, chip_id));
std::variant<int> val = vrSettingsReq;
- ctx->bus->yield_method_call(ctx->yield, ec, ACCEL_POWER_SERVICE,
- object_name.c_str(),
- "org.freedesktop.DBus.Properties", "Set",
- POWER_MODE_IFC, "PowerMode", val);
+ ctx->bus->yield_method_call(
+ ctx->yield, ec, ACCEL_POWER_SERVICE, object_name.c_str(),
+ "org.freedesktop.DBus.Properties", "Set", POWER_MODE_IFC, "PowerMode",
+ val);
if (ec)
{
log<level::ERR>("Failed to set PowerMode property");
@@ -747,9 +747,9 @@
{
Value value;
boost::system::error_code ec;
- std::string object_name(std::format("{}{}{}", EXTERNAL_SENSOR_PATH_PREFIX,
- _vrSettingsMap.at(settings_id),
- chip_id));
+ std::string object_name(
+ std::format("{}{}{}", EXTERNAL_SENSOR_PATH_PREFIX,
+ _vrSettingsMap.at(settings_id), chip_id));
if (_vrSettingsMap.find(settings_id) == _vrSettingsMap.end())
{
diff --git a/handler_impl.hpp b/handler_impl.hpp
index dc00051..8636d3c 100644
--- a/handler_impl.hpp
+++ b/handler_impl.hpp
@@ -43,11 +43,11 @@
explicit Handler(const std::string& entityConfigPath = defaultConfigFile) :
fsPtr(std::make_unique<FileSystemWrapper>()),
_configFile(entityConfigPath),
- bifurcationHelper(BifurcationStatic::createBifurcation()){};
+ bifurcationHelper(BifurcationStatic::createBifurcation()) {};
Handler(std::reference_wrapper<BifurcationInterface> bifurcationHelper,
const std::string& entityConfigPath = defaultConfigFile) :
fsPtr(std::make_unique<FileSystemWrapper>()),
- _configFile(entityConfigPath), bifurcationHelper(bifurcationHelper){};
+ _configFile(entityConfigPath), bifurcationHelper(bifurcationHelper) {};
~Handler() = default;
uint8_t getBmcMode() override;
diff --git a/main.cpp b/main.cpp
index 69d9c04..baf2a64 100644
--- a/main.cpp
+++ b/main.cpp
@@ -50,12 +50,13 @@
stderr, "Registering OEM:[{:#08X}], Cmd:[{:#04X}] for Sys Commands\n",
oem::googOemNumber, oem::google::sysCmd);
- ::ipmi::registerOemHandler(::ipmi::prioOemBase, oem::googOemNumber,
- oem::google::sysCmd, ::ipmi::Privilege::User,
- [](::ipmi::Context::ptr ctx, uint8_t cmd,
- const std::vector<uint8_t>& data) {
- return handleSysCommand(&handlerImpl, ctx, cmd, data);
- });
+ ::ipmi::registerOemHandler(
+ ::ipmi::prioOemBase, oem::googOemNumber, oem::google::sysCmd,
+ ::ipmi::Privilege::User,
+ [](::ipmi::Context::ptr ctx, uint8_t cmd,
+ const std::vector<uint8_t>& data) {
+ return handleSysCommand(&handlerImpl, ctx, cmd, data);
+ });
}
} // namespace ipmi
diff --git a/pcie_i2c.cpp b/pcie_i2c.cpp
index 0f95992..0a59738 100644
--- a/pcie_i2c.cpp
+++ b/pcie_i2c.cpp
@@ -97,8 +97,8 @@
}
std::vector<std::uint8_t> reply;
- reply.reserve(pcie_slot_name.length() +
- sizeof(struct PcieSlotI2cBusMappingReply));
+ reply.reserve(
+ pcie_slot_name.length() + sizeof(struct PcieSlotI2cBusMappingReply));
// Copy the i2c bus number and the pcie slot name to the reply struct.
reply.emplace_back(i2c_bus_number); /* i2c_bus_number */
reply.emplace_back(pcie_slot_name.length()); /* pcie_slot_name length */
diff --git a/test/bm_mode_transition_unittest.cpp b/test/bm_mode_transition_unittest.cpp
index b39d56c..2302734 100644
--- a/test/bm_mode_transition_unittest.cpp
+++ b/test/bm_mode_transition_unittest.cpp
@@ -45,8 +45,7 @@
{
public:
MockFsHandler(std::unique_ptr<FileSystemMock> mock,
- const std::string& config = "") :
- Handler(config)
+ const std::string& config = "") : Handler(config)
{
fsPtr_ = move(mock);
}
diff --git a/test/eth_unittest.cpp b/test/eth_unittest.cpp
index 14b0875..50c9ed7 100644
--- a/test/eth_unittest.cpp
+++ b/test/eth_unittest.cpp
@@ -53,9 +53,9 @@
EXPECT_EQ(SysOEMCommands::SysGetEthDevice, result.first);
EXPECT_EQ(expectedChannel, data[0]);
EXPECT_EQ(expectedAnswer.size(), data[1]);
- EXPECT_EQ(
- expectedAnswer.data(),
- std::string(data.begin() + sizeof(struct EthDeviceReply), data.end()));
+ EXPECT_EQ(expectedAnswer.data(),
+ std::string(data.begin() + sizeof(struct EthDeviceReply),
+ data.end()));
}
TEST(EthCommandTest, ValidPopulatedReturnsSuccess)
@@ -77,9 +77,9 @@
EXPECT_EQ(SysOEMCommands::SysGetEthDevice, result.first);
EXPECT_EQ(expectedChannel, data[0]);
EXPECT_EQ(expectedAnswer.size(), data[1]);
- EXPECT_EQ(
- expectedAnswer.data(),
- std::string(data.begin() + sizeof(struct EthDeviceReply), data.end()));
+ EXPECT_EQ(expectedAnswer.data(),
+ std::string(data.begin() + sizeof(struct EthDeviceReply),
+ data.end()));
}
} // namespace ipmi
} // namespace google
diff --git a/test/handler_unittest.cpp b/test/handler_unittest.cpp
index 2fb470e..5d01b73 100644
--- a/test/handler_unittest.cpp
+++ b/test/handler_unittest.cpp
@@ -142,8 +142,7 @@
public:
MockDbusHandler(sdbusplus::SdBusMock& mock,
const std::string& config = "") :
- Handler(config),
- mock_(&mock)
+ Handler(config), mock_(&mock)
{}
protected:
@@ -305,11 +304,11 @@
const std::string& service, const std::string& objPath,
const std::string& interface, const std::string& function)
{
- EXPECT_CALL(
- mock, sd_bus_message_new_method_call(_, // sd_bus *bus,
- NotNull(), // sd_bus_message **m
- StrEq(service), StrEq(objPath),
- StrEq(interface), StrEq(function)))
+ EXPECT_CALL(mock, sd_bus_message_new_method_call(
+ _, // sd_bus *bus,
+ NotNull(), // sd_bus_message **m
+ StrEq(service), StrEq(objPath), StrEq(interface),
+ StrEq(function)))
.WillOnce(Return(-ENOTCONN));
}
@@ -383,11 +382,11 @@
StrEq("com.google.custom_accel.BAR"), StrEq("Read")))
.WillOnce(DoAll(SetArgPointee<1>(method), Return(0)));
- EXPECT_CALL(
- mock, sd_bus_message_append_basic(
- method, SD_BUS_TYPE_UINT64,
- MatcherCast<const void*>(
- SafeMatcherCast<const uint64_t*>(Pointee(Eq(address))))))
+ EXPECT_CALL(mock,
+ sd_bus_message_append_basic(
+ method, SD_BUS_TYPE_UINT64,
+ MatcherCast<const void*>(SafeMatcherCast<const uint64_t*>(
+ Pointee(Eq(address))))))
.WillOnce(Return(1));
EXPECT_CALL(mock,
@@ -515,11 +514,11 @@
.WillOnce(DoAll(TraceDbus("sd_bus_message_new_method_call"),
SetArgPointee<1>(method), Return(0)));
- EXPECT_CALL(
- mock, sd_bus_message_append_basic(
- method, SD_BUS_TYPE_UINT64,
- MatcherCast<const void*>(
- SafeMatcherCast<const uint64_t*>(Pointee(Eq(address))))))
+ EXPECT_CALL(mock,
+ sd_bus_message_append_basic(
+ method, SD_BUS_TYPE_UINT64,
+ MatcherCast<const void*>(SafeMatcherCast<const uint64_t*>(
+ Pointee(Eq(address))))))
.WillOnce(DoAll(TraceDbus("sd_bus_message_append_basic(address) -> 1"),
Return(1)));
diff --git a/test/helper.cpp b/test/helper.cpp
index 191c944..1c6d76a 100644
--- a/test/helper.cpp
+++ b/test/helper.cpp
@@ -25,9 +25,8 @@
namespace ipmi
{
-std::pair<std::uint8_t, std::vector<std::uint8_t>>
- ValidateReply(::ipmi::RspType<std::uint8_t, std::vector<uint8_t>> reply,
- bool hasData)
+std::pair<std::uint8_t, std::vector<std::uint8_t>> ValidateReply(
+ ::ipmi::RspType<std::uint8_t, std::vector<uint8_t>> reply, bool hasData)
{
// Reply is in the form of
// std::tuple<ipmi::Cc, std::optional<std::tuple<RetTypes...>>>