From 444b5ea4847ea7c014114094d4b63672122f9786 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Fri, 19 May 2023 13:56:42 -0500 Subject: [PATCH] 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: I0a1783b101aa4e7d4b80fd5e1fc1b2beb86c5caa --- .clang-format | 59 +++++++++++++++++++++++------- bifurcation/bifurcation_static.cpp | 11 +++--- bmc_mode.cpp | 1 + bmc_mode.hpp | 1 + cable.cpp | 3 +- cable.hpp | 1 + cpld.cpp | 3 +- cpld.hpp | 1 + entity_name.cpp | 7 ++-- entity_name.hpp | 1 + errors.hpp | 3 +- eth.cpp | 3 +- eth.hpp | 1 + flash_size.cpp | 3 +- flash_size.hpp | 1 + google_accel_oob.cpp | 3 +- handler.cpp | 23 ++++++------ handler.hpp | 3 +- handler_impl.hpp | 5 ++- host_power_off.cpp | 3 +- host_power_off.hpp | 1 + ipmi.cpp | 5 ++- ipmi.hpp | 1 + machine_name.cpp | 3 +- machine_name.hpp | 1 + main.cpp | 12 +++--- pcie_bifurcation.cpp | 1 + pcie_i2c.cpp | 7 ++-- pcie_i2c.hpp | 1 + psu.cpp | 3 +- psu.hpp | 1 + test/handler_mock.hpp | 1 - test/handler_unittest.cpp | 10 ++--- test/helper.cpp | 1 + test/helper.hpp | 1 + util.cpp | 9 +++-- util.hpp | 3 +- 37 files changed, 128 insertions(+), 69 deletions(-) diff --git a/.clang-format b/.clang-format index ea71ad6..4922cf6 100644 --- a/.clang-format +++ b/.clang-format @@ -5,22 +5,24 @@ AccessModifierOffset: -2 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 @@ BraceWrapping: 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,30 @@ ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] 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 +IndentExternBlock: NoIndent +IndentRequiresClause: true IndentWidth: 4 IndentWrappedFunctionNames: true -KeepEmptyLinesAtTheStartOfBlocks: true +InsertNewlineAtEOF: true +KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: OuterScope +LineEnding: LF MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 @@ -73,18 +93,29 @@ NamespaceIndentation: None 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 +123,7 @@ SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: Cpp11 +Standard: Latest TabWidth: 4 UseTab: Never ... diff --git a/bifurcation/bifurcation_static.cpp b/bifurcation/bifurcation_static.cpp index 66b0c9a..c4b0f89 100644 --- a/bifurcation/bifurcation_static.cpp +++ b/bifurcation/bifurcation_static.cpp @@ -17,10 +17,11 @@ #include +#include + #include #include #include -#include #include #include #include @@ -32,13 +33,11 @@ namespace ipmi BifurcationStatic::BifurcationStatic() : BifurcationStatic(STATIC_BIFURCATION_CONFIG) -{ -} +{} BifurcationStatic::BifurcationStatic(std::string_view bifurcationFile) : bifurcationFile(bifurcationFile) -{ -} +{} std::optional> BifurcationStatic::getBifurcation(uint8_t index) noexcept @@ -77,7 +76,7 @@ std::optional> auto value = jsonData[key]; value.get_to(vec); } - catch (std::exception const& e) + catch (const std::exception& e) { fmt::print(stderr, "Failed to convert bifurcation value to vec[uin8_t]\n"); diff --git a/bmc_mode.cpp b/bmc_mode.cpp index b3af71d..4964c56 100644 --- a/bmc_mode.cpp +++ b/bmc_mode.cpp @@ -19,6 +19,7 @@ #include "handler.hpp" #include + #include #include diff --git a/bmc_mode.hpp b/bmc_mode.hpp index ee80d54..9d9b4f1 100644 --- a/bmc_mode.hpp +++ b/bmc_mode.hpp @@ -19,6 +19,7 @@ #include #include + #include namespace google diff --git a/cable.cpp b/cable.cpp index cac7fea..6253579 100644 --- a/cable.cpp +++ b/cable.cpp @@ -18,9 +18,10 @@ #include "errors.hpp" #include "handler.hpp" +#include + #include #include -#include #include #include #include diff --git a/cable.hpp b/cable.hpp index 138ade0..0923214 100644 --- a/cable.hpp +++ b/cable.hpp @@ -19,6 +19,7 @@ #include #include + #include namespace google diff --git a/cpld.cpp b/cpld.cpp index e5dc276..a6e30e5 100644 --- a/cpld.cpp +++ b/cpld.cpp @@ -18,8 +18,9 @@ #include "errors.hpp" #include "handler.hpp" -#include #include + +#include #include #include diff --git a/cpld.hpp b/cpld.hpp index 9f4d169..074fd5f 100644 --- a/cpld.hpp +++ b/cpld.hpp @@ -19,6 +19,7 @@ #include #include + #include namespace google diff --git a/entity_name.cpp b/entity_name.cpp index 5ded4a0..8048ce8 100644 --- a/entity_name.cpp +++ b/entity_name.cpp @@ -18,9 +18,10 @@ #include "errors.hpp" #include "handler.hpp" +#include + #include #include -#include #include #include #include @@ -61,8 +62,8 @@ Resp getEntityName(std::span data, HandlerInterface* handler) 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/entity_name.hpp b/entity_name.hpp index d1a9913..3a3e149 100644 --- a/entity_name.hpp +++ b/entity_name.hpp @@ -19,6 +19,7 @@ #include #include + #include #include diff --git a/errors.hpp b/errors.hpp index 33d1a8c..1db59c3 100644 --- a/errors.hpp +++ b/errors.hpp @@ -32,8 +32,7 @@ class IpmiException : public std::exception explicit IpmiException(int ipmicc) : _message("IPMI Code Received: " + std::to_string(ipmicc)), _ipmicc(ipmicc) - { - } + {} virtual const char* what() const noexcept override { diff --git a/eth.cpp b/eth.cpp index 748aa18..0c76106 100644 --- a/eth.cpp +++ b/eth.cpp @@ -17,9 +17,10 @@ #include "commands.hpp" #include "handler.hpp" +#include + #include #include -#include #include #include #include diff --git a/eth.hpp b/eth.hpp index 67ed7b9..6f91bfe 100644 --- a/eth.hpp +++ b/eth.hpp @@ -19,6 +19,7 @@ #include #include + #include namespace google diff --git a/flash_size.cpp b/flash_size.cpp index 339b81c..df23f4f 100644 --- a/flash_size.cpp +++ b/flash_size.cpp @@ -18,9 +18,10 @@ #include "errors.hpp" #include "handler.hpp" +#include + #include #include -#include #include #include #include diff --git a/flash_size.hpp b/flash_size.hpp index 34c5549..58bd149 100644 --- a/flash_size.hpp +++ b/flash_size.hpp @@ -19,6 +19,7 @@ #include #include + #include namespace google diff --git a/google_accel_oob.cpp b/google_accel_oob.cpp index e0fa615..8207f6e 100644 --- a/google_accel_oob.cpp +++ b/google_accel_oob.cpp @@ -16,9 +16,10 @@ #include "commands.hpp" +#include + #include #include -#include #include #include #include diff --git a/handler.cpp b/handler.cpp index a82c401..9bbd082 100644 --- a/handler.cpp +++ b/handler.cpp @@ -13,6 +13,8 @@ // limitations under the License. #include "handler.hpp" +#include "bm_config.h" + #include "bmc_mode_enum.hpp" #include "errors.hpp" #include "handler_impl.hpp" @@ -25,23 +27,22 @@ #include #include +#include +#include +#include +#include +#include + #include #include #include #include #include -#include -#include -#include -#include #include #include #include #include #include -#include - -#include "bm_config.h" #ifndef NCSI_IF_NAME #define NCSI_IF_NAME eth0 @@ -174,10 +175,10 @@ VersionTuple Handler::getCpldVersion(unsigned int id) const // 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) { std::fprintf(stderr, "Invalid version.\n"); diff --git a/handler.hpp b/handler.hpp index 9ac3bb7..3b0a372 100644 --- a/handler.hpp +++ b/handler.hpp @@ -14,8 +14,9 @@ #pragma once -#include #include + +#include #include #include #include diff --git a/handler_impl.hpp b/handler_impl.hpp index b4e87c6..bad01f1 100644 --- a/handler_impl.hpp +++ b/handler_impl.hpp @@ -17,10 +17,11 @@ #include "bifurcation.hpp" #include "handler.hpp" -#include -#include #include #include + +#include +#include #include #include #include diff --git a/host_power_off.cpp b/host_power_off.cpp index ac19bad..fa3a37d 100644 --- a/host_power_off.cpp +++ b/host_power_off.cpp @@ -18,9 +18,10 @@ #include "errors.hpp" #include "handler.hpp" +#include + #include #include -#include #include #include diff --git a/host_power_off.hpp b/host_power_off.hpp index 0cbe9c2..38555f2 100644 --- a/host_power_off.hpp +++ b/host_power_off.hpp @@ -19,6 +19,7 @@ #include #include + #include #include diff --git a/ipmi.cpp b/ipmi.cpp index c296e63..636cfa5 100644 --- a/ipmi.cpp +++ b/ipmi.cpp @@ -31,10 +31,11 @@ #include -#include -#include #include #include + +#include +#include #include #include diff --git a/ipmi.hpp b/ipmi.hpp index 8194f0f..95683b9 100644 --- a/ipmi.hpp +++ b/ipmi.hpp @@ -20,6 +20,7 @@ #include #include + #include #include diff --git a/machine_name.cpp b/machine_name.cpp index 4946cd6..c06ce5c 100644 --- a/machine_name.cpp +++ b/machine_name.cpp @@ -17,10 +17,11 @@ #include "commands.hpp" #include "errors.hpp" +#include + #include #include #include -#include #include #include #include diff --git a/machine_name.hpp b/machine_name.hpp index 13baadd..ff0f7fa 100644 --- a/machine_name.hpp +++ b/machine_name.hpp @@ -19,6 +19,7 @@ #include #include + #include namespace google diff --git a/main.cpp b/main.cpp index e903e1c..061c15f 100644 --- a/main.cpp +++ b/main.cpp @@ -17,12 +17,13 @@ #include -#include -#include -#include #include #include #include + +#include +#include +#include #include namespace oem @@ -52,9 +53,8 @@ void setupGoogleOemSysCommands() oem::google::sysCmd, ::ipmi::Privilege::User, [](::ipmi::Context::ptr ctx, uint8_t cmd, const std::vector& data) { - return handleSysCommand(&handlerImpl, ctx, - cmd, data); - }); + return handleSysCommand(&handlerImpl, ctx, cmd, data); + }); } } // namespace ipmi diff --git a/pcie_bifurcation.cpp b/pcie_bifurcation.cpp index faa6bd9..dade4ed 100644 --- a/pcie_bifurcation.cpp +++ b/pcie_bifurcation.cpp @@ -23,6 +23,7 @@ #include #include + #include #include diff --git a/pcie_i2c.cpp b/pcie_i2c.cpp index 8a8b839..854609c 100644 --- a/pcie_i2c.cpp +++ b/pcie_i2c.cpp @@ -17,9 +17,10 @@ #include "commands.hpp" #include "handler.hpp" +#include + #include #include -#include #include #include #include @@ -84,8 +85,8 @@ Resp pcieSlotI2cBusMapping(std::span data, uint32_t i2c_bus_number = std::get<0>(i2cEntry); std::string pcie_slot_name = std::get<1>(i2cEntry); - int length = - sizeof(struct PcieSlotI2cBusMappingReply) + pcie_slot_name.length(); + int length = sizeof(struct PcieSlotI2cBusMappingReply) + + pcie_slot_name.length(); // TODO (jaghu) : Add a way to dynamically receive the MAX_IPMI_BUFFER // value and change error to IPMI_CC_REQUESTED_TOO_MANY_BYTES. diff --git a/pcie_i2c.hpp b/pcie_i2c.hpp index 63d4df8..70b002f 100644 --- a/pcie_i2c.hpp +++ b/pcie_i2c.hpp @@ -19,6 +19,7 @@ #include #include + #include namespace google diff --git a/psu.cpp b/psu.cpp index 32a3fe2..7f7a5b3 100644 --- a/psu.cpp +++ b/psu.cpp @@ -18,9 +18,10 @@ #include "errors.hpp" #include "handler.hpp" +#include + #include #include -#include #include #include diff --git a/psu.hpp b/psu.hpp index 56beb61..a7f0ce7 100644 --- a/psu.hpp +++ b/psu.hpp @@ -19,6 +19,7 @@ #include #include + #include namespace google diff --git a/test/handler_mock.hpp b/test/handler_mock.hpp index 580b043..9e9b71e 100644 --- a/test/handler_mock.hpp +++ b/test/handler_mock.hpp @@ -31,7 +31,6 @@ namespace ipmi class HandlerMock : public HandlerInterface { - public: ~HandlerMock() = default; diff --git a/test/handler_unittest.cpp b/test/handler_unittest.cpp index 9656364..b385321 100644 --- a/test/handler_unittest.cpp +++ b/test/handler_unittest.cpp @@ -18,13 +18,14 @@ #include +#include +#include +#include + #include #include #include #include -#include -#include -#include #include #include @@ -142,8 +143,7 @@ class MockDbusHandler : public Handler const std::string& config = "") : Handler(config), mock_(&mock) - { - } + {} protected: sdbusplus::bus_t getDbus() const override diff --git a/test/helper.cpp b/test/helper.cpp index d2c6169..191c944 100644 --- a/test/helper.cpp +++ b/test/helper.cpp @@ -15,6 +15,7 @@ #include "helper.hpp" #include + #include #include #include diff --git a/test/helper.hpp b/test/helper.hpp index d7be3d1..c76fc37 100644 --- a/test/helper.hpp +++ b/test/helper.hpp @@ -17,6 +17,7 @@ #include "handler_mock.hpp" #include + #include #include diff --git a/util.cpp b/util.cpp index 2540fe9..95e4d12 100644 --- a/util.cpp +++ b/util.cpp @@ -14,17 +14,18 @@ #include "util.hpp" +#include +#include +#include + #include #include #include #include -#include -#include #include #include #include #include -#include namespace google { @@ -71,7 +72,7 @@ std::string readPropertyFile(const std::string& fileName) // If the last character is a null terminator; remove it. if (!contents.empty()) { - char const& back = contents.back(); + const char& back = contents.back(); if (back == '\0') contents.pop_back(); } diff --git a/util.hpp b/util.hpp index bfd5546..83e0b13 100644 --- a/util.hpp +++ b/util.hpp @@ -14,8 +14,9 @@ #pragma once -#include #include + +#include #include #include #include