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
diff --git a/.clang-format b/.clang-format
index ea71ad6..4922cf6 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,30 @@
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 @@
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 @@
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 <fmt/format.h>
+#include <nlohmann/json.hpp>
+
#include <charconv>
#include <filesystem>
#include <fstream>
-#include <nlohmann/json.hpp>
#include <optional>
#include <string_view>
#include <vector>
@@ -32,13 +33,11 @@
BifurcationStatic::BifurcationStatic() :
BifurcationStatic(STATIC_BIFURCATION_CONFIG)
-{
-}
+{}
BifurcationStatic::BifurcationStatic(std::string_view bifurcationFile) :
bifurcationFile(bifurcationFile)
-{
-}
+{}
std::optional<std::vector<uint8_t>>
BifurcationStatic::getBifurcation(uint8_t index) noexcept
@@ -77,7 +76,7 @@
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 <ipmid/api-types.hpp>
+
#include <span>
#include <vector>
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 <ipmid/api.h>
#include <ipmid/api-types.hpp>
+
#include <span>
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 <ipmid/api-types.hpp>
+
#include <cstdint>
#include <cstring>
-#include <ipmid/api-types.hpp>
#include <span>
#include <string>
#include <vector>
diff --git a/cable.hpp b/cable.hpp
index 138ade0..0923214 100644
--- a/cable.hpp
+++ b/cable.hpp
@@ -19,6 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
+
#include <span>
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 <cstring>
#include <ipmid/api-types.hpp>
+
+#include <cstring>
#include <span>
#include <vector>
diff --git a/cpld.hpp b/cpld.hpp
index 9f4d169..074fd5f 100644
--- a/cpld.hpp
+++ b/cpld.hpp
@@ -19,6 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
+
#include <span>
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 <ipmid/api-types.hpp>
+
#include <cstdint>
#include <cstring>
-#include <ipmid/api-types.hpp>
#include <span>
#include <string>
#include <vector>
@@ -61,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/entity_name.hpp b/entity_name.hpp
index d1a9913..3a3e149 100644
--- a/entity_name.hpp
+++ b/entity_name.hpp
@@ -19,6 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
+
#include <span>
#include <vector>
diff --git a/errors.hpp b/errors.hpp
index 33d1a8c..1db59c3 100644
--- a/errors.hpp
+++ b/errors.hpp
@@ -32,8 +32,7 @@
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 <ipmid/api-types.hpp>
+
#include <cstdint>
#include <cstring>
-#include <ipmid/api-types.hpp>
#include <span>
#include <string>
#include <tuple>
diff --git a/eth.hpp b/eth.hpp
index 67ed7b9..6f91bfe 100644
--- a/eth.hpp
+++ b/eth.hpp
@@ -19,6 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
+
#include <span>
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 <ipmid/api-types.hpp>
+
#include <cstdint>
#include <cstring>
-#include <ipmid/api-types.hpp>
#include <span>
#include <string>
#include <vector>
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 <ipmid/api.h>
#include <ipmid/api-types.hpp>
+
#include <span>
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 <sdbusplus/bus.hpp>
+
#include <cstdint>
#include <cstring>
-#include <sdbusplus/bus.hpp>
#include <span>
#include <string>
#include <vector>
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 <sys/ioctl.h>
#include <unistd.h>
+#include <nlohmann/json.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
#include <cinttypes>
#include <cstdio>
#include <filesystem>
#include <fstream>
#include <map>
-#include <nlohmann/json.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
-#include <sdbusplus/bus.hpp>
#include <sstream>
#include <string>
#include <string_view>
#include <tuple>
#include <variant>
-#include <xyz/openbmc_project/Common/error.hpp>
-
-#include "bm_config.h"
#ifndef NCSI_IF_NAME
#define NCSI_IF_NAME eth0
@@ -174,10 +175,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)
{
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 <cstdint>
#include <ipmid/api-types.hpp>
+
+#include <cstdint>
#include <map>
#include <span>
#include <string>
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 <cstdint>
-#include <map>
#include <nlohmann/json.hpp>
#include <sdbusplus/bus.hpp>
+
+#include <cstdint>
+#include <map>
#include <string>
#include <string_view>
#include <tuple>
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 <ipmid/api-types.hpp>
+
#include <cstdint>
#include <cstring>
-#include <ipmid/api-types.hpp>
#include <span>
#include <vector>
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 <ipmid/api.h>
#include <ipmid/api-types.hpp>
+
#include <span>
#include <vector>
diff --git a/ipmi.cpp b/ipmi.cpp
index c296e63..636cfa5 100644
--- a/ipmi.cpp
+++ b/ipmi.cpp
@@ -31,10 +31,11 @@
#include <ipmid/api.h>
-#include <cstdint>
-#include <cstdio>
#include <ipmid/api-types.hpp>
#include <ipmid/message.hpp>
+
+#include <cstdint>
+#include <cstdio>
#include <optional>
#include <span>
diff --git a/ipmi.hpp b/ipmi.hpp
index 8194f0f..95683b9 100644
--- a/ipmi.hpp
+++ b/ipmi.hpp
@@ -20,6 +20,7 @@
#include <ipmid/api-types.hpp>
#include <ipmid/message.hpp>
+
#include <optional>
#include <span>
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 <ipmid/api-types.hpp>
+
#include <cstddef>
#include <cstdio>
#include <cstring>
-#include <ipmid/api-types.hpp>
#include <optional>
#include <span>
#include <string>
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 <ipmid/api.h>
#include <ipmid/api-types.hpp>
+
#include <span>
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 <ipmid/api.h>
-#include <cstdint>
-#include <cstdio>
-#include <functional>
#include <ipmid/api-types.hpp>
#include <ipmid/handler.hpp>
#include <ipmid/iana.hpp>
+
+#include <cstdint>
+#include <cstdio>
+#include <functional>
#include <span>
namespace oem
@@ -52,9 +53,8 @@
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);
- });
+ 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 <fmt/format.h>
#include <ipmid/api-types.hpp>
+
#include <span>
#include <vector>
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 <ipmid/api-types.hpp>
+
#include <cstdint>
#include <cstring>
-#include <ipmid/api-types.hpp>
#include <span>
#include <string>
#include <tuple>
@@ -84,8 +85,8 @@
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 <ipmid/api.h>
#include <ipmid/api-types.hpp>
+
#include <span>
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 <ipmid/api-types.hpp>
+
#include <cstdint>
#include <cstring>
-#include <ipmid/api-types.hpp>
#include <span>
#include <vector>
diff --git a/psu.hpp b/psu.hpp
index 56beb61..a7f0ce7 100644
--- a/psu.hpp
+++ b/psu.hpp
@@ -19,6 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
+
#include <span>
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 @@
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 <systemd/sd-bus.h>
+#include <nlohmann/json.hpp>
+#include <sdbusplus/message.hpp>
+#include <sdbusplus/test/sdbus_mock.hpp>
+
#include <charconv>
#include <filesystem>
#include <fstream>
#include <functional>
-#include <nlohmann/json.hpp>
-#include <sdbusplus/message.hpp>
-#include <sdbusplus/test/sdbus_mock.hpp>
#include <string>
#include <tuple>
@@ -142,8 +143,7 @@
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 <ipmid/api-types.hpp>
+
#include <optional>
#include <span>
#include <utility>
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 <ipmid/api-types.hpp>
+
#include <span>
#include <utility>
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 <nlohmann/json.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
#include <cstdint>
#include <cstdio>
#include <filesystem>
#include <fstream>
-#include <nlohmann/json.hpp>
-#include <phosphor-logging/elog-errors.hpp>
#include <regex>
#include <string>
#include <tuple>
#include <vector>
-#include <xyz/openbmc_project/Common/error.hpp>
namespace google
{
@@ -71,7 +72,7 @@
// 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 <cstdint>
#include <nlohmann/json.hpp>
+
+#include <cstdint>
#include <string>
#include <tuple>
#include <vector>