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: I509c8567baedea7c86787f2e880900da13ebfc9f
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index ea71ad6..d92a3f1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -5,22 +5,24 @@
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
-AlignEscapedNewlinesLeft: false
-AlignOperands: true
-AlignTrailingComments: true
+AlignEscapedNewlines: Right
+AlignOperands: Align
+AlignTrailingComments:
+ Kind: Always
+ OverEmptyLines: 1
AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
+AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
-AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
-AlwaysBreakTemplateDeclarations: true
+AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
+ AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
@@ -29,19 +31,28 @@
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
+ AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
+BreakAfterAttributes: Never
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
+BreakInheritanceList: AfterColon
+BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
+DeriveLineEnding: false
DerivePointerAlignment: false
PointerAlignment: Left
DisableFormat: false
@@ -51,21 +62,29 @@
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^[<"](gtest|gmock)'
- Priority: 5
+ Priority: 7
- Regex: '^"config.h"'
Priority: -1
- - Regex: '^".*\.hpp"'
+ - Regex: '^".*\.h"'
Priority: 1
- - Regex: '^<.*\.h>'
+ - Regex: '^".*\.hpp"'
Priority: 2
- - Regex: '^<.*'
+ - Regex: '^<.*\.h>'
Priority: 3
- - Regex: '.*'
+ - Regex: '^<.*\.hpp>'
Priority: 4
+ - Regex: '^<.*'
+ Priority: 5
+ - Regex: '.*'
+ Priority: 6
IndentCaseLabels: true
+IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: OuterScope
+LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -73,18 +92,29 @@
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 25
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
+PenaltyIndentedWhitespace: 0
+QualifierAlignment: Left
+ReferenceAlignment: Left
ReflowComments: true
+RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: Keyword
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
@@ -92,7 +122,7 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
UseTab: Never
...
diff --git a/7seg.cpp b/7seg.cpp
index da8b2ba..501c3f5 100644
--- a/7seg.cpp
+++ b/7seg.cpp
@@ -14,10 +14,11 @@
* limitations under the License.
*/
+#include <lpcsnoop/snoop_listen.hpp>
+
#include <cstdint>
#include <cstdio>
#include <filesystem>
-#include <lpcsnoop/snoop_listen.hpp>
#include <string>
namespace fs = std::filesystem;
diff --git a/ipmisnoop/ipmisnoop.hpp b/ipmisnoop/ipmisnoop.hpp
index 7e4fb46..77311b2 100644
--- a/ipmisnoop/ipmisnoop.hpp
+++ b/ipmisnoop/ipmisnoop.hpp
@@ -3,9 +3,7 @@
#include "lpcsnoop/snoop.hpp"
#include <boost/asio.hpp>
-#include <filesystem>
#include <gpiod.hpp>
-#include <iostream>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
#include <sdbusplus/asio/property.hpp>
@@ -14,6 +12,9 @@
#include <xyz/openbmc_project/Chassis/Buttons/HostSelector/server.hpp>
#include <xyz/openbmc_project/State/Boot/Raw/server.hpp>
+#include <filesystem>
+#include <iostream>
+
const std::string ipmiSnoopObject = "/xyz/openbmc_project/state/boot/raw";
const int hostParseIdx = 3;
@@ -43,9 +44,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
@@ -71,76 +72,75 @@
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 dispay and Get Selector position can be skipped in
- those platforms.
- */
- if (!sevenSegmentLedEnabled)
+ /* sevenSegmentLedEnabled flag is set when GPIO pins are not
+ there 7 seg display for fewer platforms. So, the code for
+ postcode dispay 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)
{
- return;
+ fprintf(stderr, "Error in display the postcode\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");
- }
+ }
+ else
+ {
+ fprintf(stderr, "Host Selector Position and host "
+ "number is not matched..\n");
+ }
+ }
+ else
+ {
+ fprintf(stderr, "invalid postcode value \n");
+ }
})
- {
- }
+ {}
sdbusplus::bus_t& bus;
sdbusplus::bus::match_t propertiesChangedSignalRaw;
diff --git a/lpcsnoop/snoop.hpp b/lpcsnoop/snoop.hpp
index f04c090..9d11ac3 100644
--- a/lpcsnoop/snoop.hpp
+++ b/lpcsnoop/snoop.hpp
@@ -24,7 +24,6 @@
PostObject(bus, objPath,
defer ? PostObject::action::defer_emit
: PostObject::action::emit_object_added)
- {
- }
+ {}
unsigned int rateLimit = 0;
};
diff --git a/lpcsnoop/snoop_listen.hpp b/lpcsnoop/snoop_listen.hpp
index 3a3682b..21bb01c 100644
--- a/lpcsnoop/snoop_listen.hpp
+++ b/lpcsnoop/snoop_listen.hpp
@@ -41,20 +41,17 @@
public:
SnoopListen(sdbusplus::bus_t& busIn, sd_bus_message_handler_t handler) :
signal(busIn, GetMatchRule().c_str(), handler, this)
- {
- }
+ {}
SnoopListen(sdbusplus::bus_t& busIn, message_handler_t handler) :
signal(busIn, GetMatchRule(), handler)
- {
- }
+ {}
SnoopListen(sdbusplus::bus_t& busIn, postcode_handler_t handler,
FILE* f = NULL) :
SnoopListen(busIn, std::bind(defaultMessageHandler, handler, f,
std::placeholders::_1))
- {
- }
+ {}
SnoopListen() = delete; // no default constructor
~SnoopListen() = default;
diff --git a/main.cpp b/main.cpp
index 62a08da..53a075e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -27,20 +27,21 @@
#include <systemd/sd-event.h>
#include <unistd.h>
-#include <chrono>
-#include <cstdint>
-#include <exception>
-#include <functional>
-#include <iostream>
-#include <optional>
#include <sdeventplus/event.hpp>
#include <sdeventplus/source/event.hpp>
#include <sdeventplus/source/io.hpp>
#include <sdeventplus/source/signal.hpp>
#include <sdeventplus/source/time.hpp>
#include <sdeventplus/utility/sdbus.hpp>
-#include <span>
#include <stdplus/signal.hpp>
+
+#include <chrono>
+#include <cstdint>
+#include <exception>
+#include <functional>
+#include <iostream>
+#include <optional>
+#include <span>
#include <thread>
#ifdef ENABLE_IPMI_SNOOP
@@ -69,33 +70,33 @@
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");
+ auto valPropMap = msgData.find("Position");
+ {
+ if (valPropMap == msgData.end())
{
- if (valPropMap == msgData.end())
+ 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)
{
- 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");
- }
+ fprintf(stderr, "Error in display the postcode\n");
}
}
+ }
});
}
#endif
@@ -164,11 +165,11 @@
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);
+ if (verbose)
+ {
+ fprintf(stderr, "Reenabling POST code handler\n");
+ }
+ ioSource.set_enabled(sdeventplus::source::Enabled::On);
})
.set_floating(true);
return true;
@@ -293,7 +294,6 @@
*/
int main(int argc, char* argv[])
{
-
#ifndef ENABLE_IPMI_SNOOP
int postFd = -1;
unsigned int rateLimit = 0;
@@ -335,7 +335,8 @@
case 0:
break;
#ifdef ENABLE_IPMI_SNOOP
- case 'h': {
+ case 'h':
+ {
std::string_view instances = optarg;
size_t pos = 0;
@@ -348,7 +349,8 @@
break;
}
#endif
- case 'b': {
+ case 'b':
+ {
codeSize = atoi(optarg);
if (codeSize < 1 || codeSize > 8)
@@ -371,15 +373,15 @@
return -1;
}
break;
- case 'r': {
+ case 'r':
+ {
int argVal = -1;
try
{
argVal = std::stoi(optarg);
}
catch (...)
- {
- }
+ {}
if (argVal < 1)
{
diff --git a/test/post_reporter_test.cpp b/test/post_reporter_test.cpp
index 8f7f503..ef0d0d5 100644
--- a/test/post_reporter_test.cpp
+++ b/test/post_reporter_test.cpp
@@ -20,12 +20,9 @@
{
protected:
PostReporterTest() : bus_mock(), bus(sdbusplus::get_mocked_new(&bus_mock))
- {
- }
+ {}
- ~PostReporterTest()
- {
- }
+ ~PostReporterTest() {}
NiceMock<sdbusplus::SdBusMock> bus_mock;
sdbusplus::bus_t bus;
@@ -33,7 +30,6 @@
TEST_F(PostReporterTest, EmitsObjectsOnExpectedDbusPath)
{
-
EXPECT_CALL(bus_mock,
sd_bus_emit_object_added(IsNull(), StrEq(snoopObject)))
.WillOnce(Return(0));