Skip to content

Commit 715a279

Browse files
committed
clang-format: Update to 16
1 parent 8598142 commit 715a279

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1110
-1093
lines changed

.clang-format

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
Language: Cpp
33
AccessModifierOffset: -2
44
AlignAfterOpenBracket: Align
5-
AlignConsecutiveMacros: true
65
AlignConsecutiveAssignments: false
76
AlignConsecutiveDeclarations: false
7+
AlignConsecutiveMacros: true
88
AlignEscapedNewlines: Right
99
AlignOperands: Align
10-
AlignTrailingComments: true
10+
AlignTrailingComments:
11+
Kind: Always
12+
OverEmptyLines: 0
1113
AllowAllArgumentsOnNextLine: false
1214
AllowAllConstructorInitializersOnNextLine: true
1315
AllowAllParametersOfDeclarationOnNextLine: false
1416
AllowShortBlocksOnASingleLine: Never
1517
AllowShortCaseLabelsOnASingleLine: false
1618
AllowShortFunctionsOnASingleLine: None
17-
AllowShortLambdasOnASingleLine: None
1819
AllowShortIfStatementsOnASingleLine: Never
20+
AllowShortLambdasOnASingleLine: None
1921
AllowShortLoopsOnASingleLine: false
2022
AlwaysBreakAfterDefinitionReturnType: None
2123
AlwaysBreakAfterReturnType: None
@@ -28,29 +30,30 @@ BraceWrapping:
2830
AfterClass: false
2931
AfterControlStatement: false
3032
AfterEnum: false
33+
AfterExternBlock: false
3134
AfterFunction: false
3235
AfterNamespace: false
3336
AfterObjCDeclaration: false
3437
AfterStruct: false
3538
AfterUnion: false
36-
AfterExternBlock: false
3739
BeforeCatch: false
3840
BeforeElse: false
3941
IndentBraces: true
4042
SplitEmptyFunction: true
41-
SplitEmptyRecord: true
4243
SplitEmptyNamespace: true
44+
SplitEmptyRecord: true
45+
BreakAfterAttributes: Never
46+
BreakAfterJavaFieldAnnotations: false
4347
BreakBeforeBinaryOperators: None
4448
BreakBeforeBraces: Attach
4549
BreakBeforeInheritanceComma: false
46-
BreakInheritanceList: BeforeColon
4750
BreakBeforeTernaryOperators: true
48-
BreakConstructorInitializersBeforeComma: false
4951
BreakConstructorInitializers: BeforeColon
50-
BreakAfterJavaFieldAnnotations: false
52+
BreakConstructorInitializersBeforeComma: false
53+
BreakInheritanceList: BeforeColon
5154
BreakStringLiterals: true
5255
ColumnLimit: 140
53-
CommentPragmas: '^ IWYU pragma:'
56+
CommentPragmas: "^ IWYU pragma:"
5457
CompactNamespaces: false
5558
ConstructorInitializerAllOnOneLineOrOnePerLine: true
5659
ConstructorInitializerIndentWidth: 2
@@ -75,24 +78,26 @@ IncludeCategories:
7578
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
7679
Priority: 3
7780
SortPriority: 0
78-
- Regex: '.*'
81+
- Regex: ".*"
7982
Priority: 1
8083
SortPriority: 0
81-
IncludeIsMainRegex: '(Test)?$'
82-
IncludeIsMainSourceRegex: ''
84+
IncludeIsMainRegex: "(Test)?$"
85+
IncludeIsMainSourceRegex: ""
8386
IndentAccessModifiers: false
8487
IndentCaseLabels: true
8588
IndentGotoLabels: true
8689
IndentPPDirectives: BeforeHash
8790
IndentWidth: 2
8891
IndentWrappedFunctionNames: false
89-
# Requires Clang >= 15, could also cause incorrect code formatting:
90-
# InsertBraces: true
92+
# Could lead to incorrect formatting, but I think that the tradeoff is worth it
93+
InsertBraces: true
94+
InsertNewlineAtEOF: true
9195
JavaScriptQuotes: Leave
9296
JavaScriptWrapImports: true
9397
KeepEmptyLinesAtTheStartOfBlocks: true
94-
MacroBlockBegin: ''
95-
MacroBlockEnd: ''
98+
LineEnding: LF
99+
MacroBlockBegin: ""
100+
MacroBlockEnd: ""
96101
MaxEmptyLinesToKeep: 1
97102
NamespaceIndentation: All
98103
PackConstructorInitializers: NextLine
@@ -107,35 +112,34 @@ PenaltyReturnTypeOnItsOwnLine: 60
107112
PointerAlignment: Left
108113
ReferenceAlignment: Pointer
109114
ReflowComments: true
115+
RemoveSemicolon: true
110116
SeparateDefinitionBlocks: Always
111117
SortIncludes: false
112118
SortUsingDeclarations: true
113119
SpaceAfterCStyleCast: true
114120
SpaceAfterLogicalNot: false
115121
SpaceAfterTemplateKeyword: true
122+
SpaceAroundPointerQualifiers: Default
116123
SpaceBeforeAssignmentOperators: true
117124
SpaceBeforeCaseColon: false
118125
SpaceBeforeCpp11BracedList: true
119126
SpaceBeforeCtorInitializerColon: true
120127
SpaceBeforeInheritanceColon: true
121128
SpaceBeforeParens: ControlStatementsExceptForEachMacros
122129
SpaceBeforeRangeBasedForLoopColon: true
130+
SpaceBeforeSquareBrackets: false
123131
SpaceInEmptyBlock: false
124132
SpaceInEmptyParentheses: false
125133
SpacesBeforeTrailingComments: 1
126134
SpacesInAngles: false
135+
SpacesInCStyleCastParentheses: false
127136
SpacesInConditionalStatement: false
128137
SpacesInContainerLiterals: false
129-
SpacesInCStyleCastParentheses: false
130138
SpacesInParentheses: false
131139
SpacesInSquareBrackets: false
132-
SpaceBeforeSquareBrackets: false
133-
SpaceAroundPointerQualifiers: Default
134140
Standard: Latest
135141
StatementMacros:
136142
- Q_UNUSED
137143
- QT_REQUIRE_VERSION
138144
TabWidth: 8
139-
UseCRLF: false
140145
UseTab: Never
141-
...

.github/workflows/format.yml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ name: Code formatting
22

33
on:
44
pull_request:
5-
branches: [ main ]
5+
branches: [main]
66
paths:
7-
- '**.cpp'
8-
- '**.h'
9-
- '!src/libs/**'
10-
- '!src/FreeRTOS/**'
7+
- "src/**.cpp"
8+
- "src/**.h"
9+
- "!src/libs/**"
10+
- "!src/FreeRTOS/**"
1111

1212
jobs:
1313
test-format:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
with:
1818
fetch-depth: 1000
1919

@@ -23,48 +23,48 @@ jobs:
2323
- name: Install clang-format
2424
run: |
2525
sudo apt-get update
26-
sudo apt-get -y install clang-format-14
26+
sudo apt-get -y install clang-format-16
2727
2828
- name: Check formatting
2929
run: tests/test-format.sh
3030

3131
- name: Upload patches
32-
uses: actions/upload-artifact@v3
32+
uses: actions/upload-artifact@v4
3333
if: failure()
3434
with:
3535
name: Patches
3636
path: ./*.patch
3737
test-clang-tidy:
38-
runs-on: ubuntu-latest
38+
runs-on: ubuntu-24.04
3939
container:
4040
image: infinitime/infinitime-build
4141
steps:
42-
# This workaround fixes the error "unsafe repository (REPO is owned by someone else)".
43-
# See https://github.com/actions/checkout/issues/760 and https://github.com/actions/checkout/issues/766
44-
# The fix in "actions/checkout@v2" was not sufficient as the build process also uses git (to get the current
45-
# commit hash, for example).
46-
- name: Workaround permission issues
47-
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
48-
- name: Checkout source files
49-
uses: actions/checkout@v3
50-
with:
51-
submodules: recursive
52-
fetch-depth: 1000
53-
- name: Fetch base branch
54-
run: git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF"
55-
- name: Install clang-tidy
56-
run: |
57-
apt-get update
58-
apt-get -y install clang-tidy-14
59-
- name: Prepare environment
60-
shell: bash
61-
env:
62-
SOURCES_DIR: .
63-
run: |
64-
. docker/build.sh
65-
GetGcc
66-
# I guess these already exist inside the docker?
67-
#GetNrfSdk
68-
#GetMcuBoot
69-
CmakeGenerate
70-
- run: tests/test-tidy.sh
42+
# This workaround fixes the error "unsafe repository (REPO is owned by someone else)".
43+
# See https://github.com/actions/checkout/issues/760 and https://github.com/actions/checkout/issues/766
44+
# The fix in "actions/checkout@v2" was not sufficient as the build process also uses git (to get the current
45+
# commit hash, for example).
46+
- name: Workaround permission issues
47+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
48+
- name: Checkout source files
49+
uses: actions/checkout@v4
50+
with:
51+
submodules: recursive
52+
fetch-depth: 1000
53+
- name: Fetch base branch
54+
run: git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF"
55+
- name: Install clang-tidy
56+
run: |
57+
apt-get update
58+
apt-get -y install clang-tidy-14
59+
- name: Prepare environment
60+
shell: bash
61+
env:
62+
SOURCES_DIR: .
63+
run: |
64+
. docker/build.sh
65+
GetGcc
66+
# I guess these already exist inside the docker?
67+
#GetNrfSdk
68+
#GetMcuBoot
69+
CmakeGenerate
70+
- run: tests/test-tidy.sh

hooks/pre-commit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if [ -z "$(command -v "git-$name")" ]; then
66
name="$(basename -a $(find $(echo "$PATH" | tr ':' ' ') -maxdepth 1 -type f -executable -name 'git-clang-format*') | sort | tail -n 1 | sed 's/^git-//')"
77
fi
88

9-
minVersion="14.0.0"
9+
minVersion="16.0.0"
1010

1111
for file in $(find $(echo "$PATH" | tr ':' ' ') -maxdepth 1 -type f -executable -name 'clang-format*'); do
1212
curBin="$file"
@@ -23,7 +23,7 @@ if [ -z "$name" ] || [ -z "$bin" ]; then
2323
exit 1
2424
fi
2525

26-
args="--binary $bin -q --extensions cpp,h --style file --staged -- :!src/FreeRTOS :!src/libs"
26+
args="--binary $bin -q --extensions cpp,h --style file --staged -- src :!src/FreeRTOS :!src/libs"
2727

2828
changedFiles="$(git "$name" --diffstat $args)"
2929
git "$name" $args

src/components/ble/AlertNotificationClient.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ int AlertNotificationClient::OnCharacteristicsDiscoveryEvent(uint16_t connection
8181
NRF_LOG_INFO("ANS Characteristic discovery complete");
8282
if (isCharacteristicDiscovered) {
8383
ble_gattc_disc_all_dscs(connectionHandle, newAlertHandle, ansEndHandle, OnAlertNotificationDescriptorDiscoveryEventCallback, this);
84-
} else
84+
} else {
8585
onServiceDiscovered(connectionHandle);
86+
}
8687
} else {
8788
if (characteristic != nullptr && ble_uuid_cmp(&supportedNewAlertCategoryUuid.u, &characteristic->uuid.u) == 0) {
8889
NRF_LOG_INFO("ANS Characteristic discovered : supportedNewAlertCategoryUuid");
@@ -101,8 +102,9 @@ int AlertNotificationClient::OnCharacteristicsDiscoveryEvent(uint16_t connection
101102
} else if (characteristic != nullptr && ble_uuid_cmp(&controlPointUuid.u, &characteristic->uuid.u) == 0) {
102103
NRF_LOG_INFO("ANS Characteristic discovered : controlPointUuid");
103104
controlPointHandle = characteristic->val_handle;
104-
} else
105+
} else {
105106
NRF_LOG_INFO("ANS Characteristic discovered : 0x%x", characteristic->val_handle);
107+
}
106108
}
107109
return 0;
108110
}
@@ -135,8 +137,9 @@ int AlertNotificationClient::OnDescriptorDiscoveryEventCallback(uint16_t connect
135137
}
136138
}
137139
} else {
138-
if (!isDescriptorFound)
140+
if (!isDescriptorFound) {
139141
onServiceDiscovered(connectionHandle);
142+
}
140143
}
141144
return 0;
142145
}
@@ -150,8 +153,9 @@ void AlertNotificationClient::OnNotification(ble_gap_event* event) {
150153

151154
// Ignore notifications with empty message
152155
const auto packetLen = OS_MBUF_PKTLEN(event->notify_rx.om);
153-
if (packetLen <= headerSize)
156+
if (packetLen <= headerSize) {
154157
return;
158+
}
155159

156160
size_t bufferSize = std::min(packetLen + stringTerminatorSize, maxBufferSize);
157161
auto messageSize = std::min(maxMessageSize, (bufferSize - headerSize));

src/components/ble/BleClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ namespace Pinetime {
99
virtual void Discover(uint16_t connectionHandle, std::function<void(uint16_t)> lambda) = 0;
1010
};
1111
}
12-
}
12+
}

0 commit comments

Comments
 (0)