Skip to content

Commit

Permalink
clang-format: copy latest and re-format
Browse files Browse the repository at this point in the history
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
  • Loading branch information
williamspatrick committed May 19, 2023
1 parent 6537122 commit 444b5ea
Show file tree
Hide file tree
Showing 37 changed files with 128 additions and 69 deletions.
59 changes: 45 additions & 14 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -51,48 +62,68 @@ 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
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
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
Standard: Latest
TabWidth: 4
UseTab: Never
...
Expand Down
11 changes: 5 additions & 6 deletions bifurcation/bifurcation_static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -32,13 +33,11 @@ namespace ipmi

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
Expand Down Expand Up @@ -77,7 +76,7 @@ std::optional<std::vector<uint8_t>>
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");
Expand Down
1 change: 1 addition & 0 deletions bmc_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "handler.hpp"

#include <ipmid/api-types.hpp>

#include <span>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions bmc_mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ipmid/api.h>

#include <ipmid/api-types.hpp>

#include <span>

namespace google
Expand Down
3 changes: 2 additions & 1 deletion cable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions cable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ipmid/api.h>

#include <ipmid/api-types.hpp>

#include <span>

namespace google
Expand Down
3 changes: 2 additions & 1 deletion cpld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
#include "errors.hpp"
#include "handler.hpp"

#include <cstring>
#include <ipmid/api-types.hpp>

#include <cstring>
#include <span>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions cpld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ipmid/api.h>

#include <ipmid/api-types.hpp>

#include <span>

namespace google
Expand Down
7 changes: 4 additions & 3 deletions entity_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -61,8 +62,8 @@ Resp getEntityName(std::span<const uint8_t> 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)
{
Expand Down
1 change: 1 addition & 0 deletions entity_name.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ipmid/api.h>

#include <ipmid/api-types.hpp>

#include <span>
#include <vector>

Expand Down
3 changes: 1 addition & 2 deletions errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions eth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ipmid/api.h>

#include <ipmid/api-types.hpp>

#include <span>

namespace google
Expand Down
3 changes: 2 additions & 1 deletion flash_size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions flash_size.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ipmid/api.h>

#include <ipmid/api-types.hpp>

#include <span>

namespace google
Expand Down
3 changes: 2 additions & 1 deletion google_accel_oob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
23 changes: 12 additions & 11 deletions handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

#pragma once

#include <cstdint>
#include <ipmid/api-types.hpp>

#include <cstdint>
#include <map>
#include <span>
#include <string>
Expand Down
Loading

0 comments on commit 444b5ea

Please sign in to comment.