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: Ia5d22931711ae5704dfafa0a7786909087d488ee
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/ipmisnoop/ipmisnoop.cpp b/ipmisnoop/ipmisnoop.cpp
index 64c685e..56d06d9 100644
--- a/ipmisnoop/ipmisnoop.cpp
+++ b/ipmisnoop/ipmisnoop.cpp
@@ -8,9 +8,9 @@
{
const std::string propertyName = "Position";
- auto method = bus.new_method_call(selectorService.c_str(),
- selectorObject.c_str(),
- "org.freedesktop.DBus.Properties", "Get");
+ auto method =
+ bus.new_method_call(selectorService.c_str(), selectorObject.c_str(),
+ "org.freedesktop.DBus.Properties", "Get");
method.append(selectorIface.c_str(), propertyName);
try
@@ -97,34 +97,34 @@
sdbusplus::bus::match::rules::propertiesChanged(selectorObject,
selectorIface),
[&](sdbusplus::message_t& msg) {
- std::string objectName;
- std::map<std::string, Selector::PropertiesVariant> msgData;
- msg.read(objectName, msgData);
+ std::string objectName;
+ std::map<std::string, Selector::PropertiesVariant> msgData;
+ msg.read(objectName, msgData);
- auto valPropMap = msgData.find("Position");
- {
- if (valPropMap == msgData.end())
+ auto valPropMap = msgData.find("Position");
{
- std::cerr << "Position property not found " << std::endl;
- return;
- }
-
- posVal = std::get<size_t>(valPropMap->second);
-
- if (posVal > minPositionVal && posVal < maxPositionVal)
- {
- std::tuple<uint64_t, secondary_post_code_t> postcodes =
- reporters[posVal - 1]->value();
- uint64_t postcode = std::get<uint64_t>(postcodes);
-
- // write postcode into seven segment display
- if (postCodeDisplay(postcode) < 0)
+ if (valPropMap == msgData.end())
{
- fprintf(stderr, "Error in display the postcode\n");
+ std::cerr << "Position property not found " << std::endl;
+ return;
+ }
+
+ posVal = std::get<size_t>(valPropMap->second);
+
+ if (posVal > minPositionVal && posVal < maxPositionVal)
+ {
+ std::tuple<uint64_t, secondary_post_code_t> postcodes =
+ reporters[posVal - 1]->value();
+ uint64_t postcode = std::get<uint64_t>(postcodes);
+
+ // write postcode into seven segment display
+ if (postCodeDisplay(postcode) < 0)
+ {
+ fprintf(stderr, "Error in display the postcode\n");
+ }
}
}
- }
- });
+ });
}
// handle muti-host D-bus
diff --git a/ipmisnoop/ipmisnoop.hpp b/ipmisnoop/ipmisnoop.hpp
index b8f737a..d8319ac 100644
--- a/ipmisnoop/ipmisnoop.hpp
+++ b/ipmisnoop/ipmisnoop.hpp
@@ -54,74 +54,74 @@
sdbusplus::bus::match::rules::propertiesChanged(objPath, rawIface),
[this, &bus](sdbusplus::message_t& msg) {
- using primarycode_t = uint64_t;
- using secondarycode_t = std::vector<uint8_t>;
- using postcode_t = std::tuple<primarycode_t, secondarycode_t>;
+ using primarycode_t = uint64_t;
+ using secondarycode_t = std::vector<uint8_t>;
+ using postcode_t = std::tuple<primarycode_t, secondarycode_t>;
- /* sevenSegmentLedEnabled flag is set when GPIO pins are not
- there 7 seg display for fewer platforms. So, the code for
- postcode display and Get Selector position can be skipped in
- those platforms.
- */
- if (!sevenSegmentLedEnabled)
- {
- return;
- }
-
- std::string objectName;
- std::string InterfaceName;
- std::map<std::string, std::variant<postcode_t>> msgData;
- msg.read(InterfaceName, msgData);
-
- std::filesystem::path name(msg.get_path());
- objectName = name.filename();
-
- std::string hostNumStr = objectName.substr(hostParseIdx);
- size_t hostNum = std::stoi(hostNumStr);
-
- size_t position = getSelectorPosition(bus);
-
- if (position > maxPosition)
- {
- std::cerr << "Invalid position. Position should be 1 to 4 "
- "for all hosts "
- << std::endl;
- }
-
- // Check if it was the Value property that changed.
- auto valPropMap = msgData.find("Value");
- if (valPropMap == msgData.end())
- {
- std::cerr << "Value property is not found " << std::endl;
- return;
- }
- uint64_t postcode =
- std::get<0>(std::get<postcode_t>(valPropMap->second));
-
- if (postcode <= maxPostcode)
- {
- if (position == hostNum)
- {
- uint8_t postcode_8bit =
- static_cast<uint8_t>(postcode & 0x0000FF);
-
- // write postcode into seven segment display
- if (postCodeDisplay(postcode_8bit) < 0)
+ /* sevenSegmentLedEnabled flag is set when GPIO pins are not
+ there 7 seg display for fewer platforms. So, the code for
+ postcode display and Get Selector position can be skipped in
+ those platforms.
+ */
+ if (!sevenSegmentLedEnabled)
{
- fprintf(stderr, "Error in display the postcode\n");
+ return;
}
- }
- else
- {
- fprintf(stderr, "Host Selector Position and host "
- "number is not matched..\n");
- }
- }
- else
- {
- fprintf(stderr, "invalid postcode value \n");
- }
- })
+
+ std::string objectName;
+ std::string InterfaceName;
+ std::map<std::string, std::variant<postcode_t>> msgData;
+ msg.read(InterfaceName, msgData);
+
+ std::filesystem::path name(msg.get_path());
+ objectName = name.filename();
+
+ std::string hostNumStr = objectName.substr(hostParseIdx);
+ size_t hostNum = std::stoi(hostNumStr);
+
+ size_t position = getSelectorPosition(bus);
+
+ if (position > maxPosition)
+ {
+ std::cerr << "Invalid position. Position should be 1 to 4 "
+ "for all hosts "
+ << std::endl;
+ }
+
+ // Check if it was the Value property that changed.
+ auto valPropMap = msgData.find("Value");
+ if (valPropMap == msgData.end())
+ {
+ std::cerr << "Value property is not found " << std::endl;
+ return;
+ }
+ uint64_t postcode =
+ std::get<0>(std::get<postcode_t>(valPropMap->second));
+
+ if (postcode <= maxPostcode)
+ {
+ if (position == hostNum)
+ {
+ uint8_t postcode_8bit =
+ static_cast<uint8_t>(postcode & 0x0000FF);
+
+ // write postcode into seven segment display
+ if (postCodeDisplay(postcode_8bit) < 0)
+ {
+ fprintf(stderr, "Error in display the postcode\n");
+ }
+ }
+ else
+ {
+ fprintf(stderr, "Host Selector Position and host "
+ "number is not matched..\n");
+ }
+ }
+ else
+ {
+ fprintf(stderr, "invalid postcode value \n");
+ }
+ })
{}
sdbusplus::bus_t& bus;
diff --git a/main.cpp b/main.cpp
index 4785044..e544a11 100644
--- a/main.cpp
+++ b/main.cpp
@@ -113,12 +113,13 @@
sdeventplus::source::Time<sdeventplus::ClockId::Monotonic>(
event, rateLimitEndTime, std::chrono::milliseconds(100),
[&ioSource](auto&, auto) {
- if (verbose)
- {
- fprintf(stderr, "Reenabling POST code handler\n");
- }
- ioSource.set_enabled(sdeventplus::source::Enabled::On);
- }).set_floating(true);
+ if (verbose)
+ {
+ fprintf(stderr, "Reenabling POST code handler\n");
+ }
+ ioSource.set_enabled(sdeventplus::source::Enabled::On);
+ })
+ .set_floating(true);
return true;
}
@@ -151,9 +152,9 @@
for (size_t i = 0; i < (readb / pccSize); i++)
{
- uint16_t checkCode = firstPCCPortNumber +
- ((aspeedPCCBuffer.size() % fullPostPCCCount)
- << byteShift);
+ uint16_t checkCode =
+ firstPCCPortNumber +
+ ((aspeedPCCBuffer.size() % fullPostPCCCount) << byteShift);
if (checkCode == (codePtr[i] & pccPortNumberMask))
{