Skip to content

Commit 1733a24

Browse files
committed
checkpatch: remove and use clang-format instead
checkpatch flags too many false positives in the SOF codebase to be considered useful. Notwithstanding it does not cope with assembler, matlab and topology very well. Remove and use clang-format instead which is understood by modern editors and agents for both SOF and rimage. clang-format is based on Linux clang-format with adaptations for SOF and Zephyr. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 292e21d commit 1733a24

File tree

13 files changed

+365
-14557
lines changed

13 files changed

+365
-14557
lines changed

.clang-format

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# clang-format configuration file. Intended for clang-format >= 11.
4+
#
5+
# For more information, see:
6+
#
7+
# Documentation/dev-tools/clang-format.rst
8+
# https://clang.llvm.org/docs/ClangFormat.html
9+
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
10+
#
11+
---
12+
AccessModifierOffset: -4
13+
AlignAfterOpenBracket: Align
14+
AlignConsecutiveAssignments: false
15+
AlignConsecutiveDeclarations: false
16+
AlignEscapedNewlines: Left
17+
AlignOperands: true
18+
AlignTrailingComments: false
19+
AllowAllParametersOfDeclarationOnNextLine: false
20+
AllowShortBlocksOnASingleLine: false
21+
AllowShortCaseLabelsOnASingleLine: false
22+
AllowShortFunctionsOnASingleLine: None
23+
AllowShortIfStatementsOnASingleLine: false
24+
AllowShortLoopsOnASingleLine: false
25+
AlwaysBreakAfterDefinitionReturnType: None
26+
AlwaysBreakAfterReturnType: None
27+
AlwaysBreakBeforeMultilineStrings: false
28+
AlwaysBreakTemplateDeclarations: false
29+
BinPackArguments: true
30+
BinPackParameters: true
31+
BraceWrapping:
32+
AfterClass: false
33+
AfterControlStatement: false
34+
AfterEnum: false
35+
AfterFunction: true
36+
AfterNamespace: true
37+
AfterObjCDeclaration: false
38+
AfterStruct: false
39+
AfterUnion: false
40+
AfterExternBlock: false
41+
BeforeCatch: false
42+
BeforeElse: false
43+
IndentBraces: false
44+
SplitEmptyFunction: true
45+
SplitEmptyRecord: true
46+
SplitEmptyNamespace: true
47+
BreakBeforeBinaryOperators: None
48+
BreakBeforeBraces: Custom
49+
BreakBeforeInheritanceComma: false
50+
BreakBeforeTernaryOperators: false
51+
BreakConstructorInitializersBeforeComma: false
52+
BreakConstructorInitializers: BeforeComma
53+
BreakAfterJavaFieldAnnotations: false
54+
BreakStringLiterals: false
55+
ColumnLimit: 120
56+
CommentPragmas: '^ IWYU pragma:'
57+
CompactNamespaces: false
58+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
59+
ConstructorInitializerIndentWidth: 8
60+
ContinuationIndentWidth: 8
61+
Cpp11BracedListStyle: false
62+
DerivePointerAlignment: false
63+
DisableFormat: false
64+
ExperimentalAutoDetectBinPacking: false
65+
FixNamespaceComments: false
66+
67+
# Taken from:
68+
# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ tools/ \
69+
# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
70+
# | LC_ALL=C sort -u
71+
ForEachMacros:
72+
- 'ARRAY_FOR_EACH'
73+
- 'ARRAY_FOR_EACH_PTR'
74+
- 'FOR_EACH'
75+
- 'FOR_EACH_FIXED_ARG'
76+
- 'FOR_EACH_IDX'
77+
- 'FOR_EACH_IDX_FIXED_ARG'
78+
- 'FOR_EACH_NONEMPTY_TERM'
79+
- 'FOR_EACH_FIXED_ARG_NONEMPTY_TERM'
80+
- 'RB_FOR_EACH'
81+
- 'RB_FOR_EACH_CONTAINER'
82+
- 'SYS_DLIST_FOR_EACH_CONTAINER'
83+
- 'SYS_DLIST_FOR_EACH_CONTAINER_SAFE'
84+
- 'SYS_DLIST_FOR_EACH_NODE'
85+
- 'SYS_DLIST_FOR_EACH_NODE_SAFE'
86+
- 'SYS_SEM_LOCK'
87+
- 'SYS_SFLIST_FOR_EACH_CONTAINER'
88+
- 'SYS_SFLIST_FOR_EACH_CONTAINER_SAFE'
89+
- 'SYS_SFLIST_FOR_EACH_NODE'
90+
- 'SYS_SFLIST_FOR_EACH_NODE_SAFE'
91+
- 'SYS_SLIST_FOR_EACH_CONTAINER'
92+
- 'SYS_SLIST_FOR_EACH_CONTAINER_SAFE'
93+
- 'SYS_SLIST_FOR_EACH_NODE'
94+
- 'SYS_SLIST_FOR_EACH_NODE_SAFE'
95+
- '_WAIT_Q_FOR_EACH'
96+
- '_WAIT_Q_FOR_EACH_SAFE'
97+
- 'Z_FOR_EACH'
98+
- 'Z_FOR_EACH_ENGINE'
99+
- 'Z_FOR_EACH_EXEC'
100+
- 'Z_FOR_EACH_FIXED_ARG'
101+
- 'Z_FOR_EACH_FIXED_ARG_EXEC'
102+
- 'Z_FOR_EACH_IDX'
103+
- 'Z_FOR_EACH_IDX_EXEC'
104+
- 'Z_FOR_EACH_IDX_FIXED_ARG'
105+
- 'Z_FOR_EACH_IDX_FIXED_ARG_EXEC'
106+
- 'Z_GENLIST_FOR_EACH_CONTAINER'
107+
- 'Z_GENLIST_FOR_EACH_CONTAINER_SAFE'
108+
- 'Z_GENLIST_FOR_EACH_NODE'
109+
- 'Z_GENLIST_FOR_EACH_NODE_SAFE'
110+
- 'STRUCT_SECTION_FOREACH'
111+
- 'STRUCT_SECTION_FOREACH_ALTERNATE'
112+
- 'TYPE_SECTION_FOREACH'
113+
- 'K_SPINLOCK'
114+
- 'COAP_RESOURCE_FOREACH'
115+
- 'COAP_SERVICE_FOREACH'
116+
- 'COAP_SERVICE_FOREACH_RESOURCE'
117+
- 'HTTP_RESOURCE_FOREACH'
118+
- 'HTTP_SERVER_CONTENT_TYPE_FOREACH'
119+
- 'HTTP_SERVICE_FOREACH'
120+
- 'HTTP_SERVICE_FOREACH_RESOURCE'
121+
- 'I3C_BUS_FOR_EACH_I3CDEV'
122+
- 'I3C_BUS_FOR_EACH_I2CDEV'
123+
- 'MIN_HEAP_FOREACH'
124+
- 'comp_dev_for_each_consumer'
125+
- 'comp_dev_for_each_consumer_safe'
126+
- 'comp_dev_for_each_producer'
127+
- 'comp_dev_for_each_producer_safe'
128+
129+
IncludeBlocks: Preserve
130+
IncludeCategories:
131+
- Regex: '.*'
132+
Priority: 1
133+
IncludeIsMainRegex: '(Test)?$'
134+
IndentCaseLabels: false
135+
IndentGotoLabels: false
136+
IndentPPDirectives: None
137+
IndentWidth: 4
138+
IndentWrappedFunctionNames: false
139+
JavaScriptQuotes: Leave
140+
JavaScriptWrapImports: true
141+
KeepEmptyLinesAtTheStartOfBlocks: false
142+
MacroBlockBegin: ''
143+
MacroBlockEnd: ''
144+
MaxEmptyLinesToKeep: 1
145+
NamespaceIndentation: None
146+
ObjCBinPackProtocolList: Auto
147+
ObjCBlockIndentWidth: 8
148+
ObjCSpaceAfterProperty: true
149+
ObjCSpaceBeforeProtocolList: true
150+
151+
# Taken from git's rules
152+
PenaltyBreakAssignment: 10
153+
PenaltyBreakBeforeFirstCallParameter: 30
154+
PenaltyBreakComment: 10
155+
PenaltyBreakFirstLessLess: 0
156+
PenaltyBreakString: 10
157+
PenaltyExcessCharacter: 100
158+
PenaltyReturnTypeOnItsOwnLine: 60
159+
160+
PointerAlignment: Right
161+
ReflowComments: false
162+
SortIncludes: false
163+
SortUsingDeclarations: false
164+
SpaceAfterCStyleCast: false
165+
SpaceAfterTemplateKeyword: true
166+
SpaceBeforeAssignmentOperators: true
167+
SpaceBeforeCtorInitializerColon: true
168+
SpaceBeforeInheritanceColon: true
169+
SpaceBeforeParens: ControlStatementsExceptForEachMacros
170+
SpaceBeforeRangeBasedForLoopColon: true
171+
SpaceInEmptyParentheses: false
172+
SpacesBeforeTrailingComments: 1
173+
SpacesInAngles: false
174+
SpacesInContainerLiterals: false
175+
SpacesInCStyleCastParentheses: false
176+
SpacesInParentheses: false
177+
SpacesInSquareBrackets: false
178+
Standard: Cpp03
179+
TabWidth: 4
180+
UseTab: Never
181+
...

.github/workflows/SPDX-README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Read this section if there are some SPDX warnings above.
2-
Pleasing checkpatch is hard when adding new files because:
2+
Adding correct SPDX headers to new files can be tricky because:
33

4-
- checkpatch requests a different SPDX style for .c versus .h files.
4+
- a different SPDX style is expected for .c versus .h files.
55
This is because some .h files are included in linker scripts or
66
assembly code.
77
- Some SOF reviewers reject C99 comments starting with //

.github/workflows/checkpatch_list.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/codestyle.yml

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,9 @@ name: codestyle
1414
# yamllint disable-line rule:truthy
1515
on: [pull_request, workflow_call, workflow_dispatch]
1616

17-
jobs:
18-
checkpatch:
19-
runs-on: ubuntu-22.04
20-
21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
strictness: [null, --subjective]
25-
26-
env:
27-
PR_NUM: ${{github.event.number}}
28-
# TODO: reduce duplication with scripts/sof-*-commit-hook.sh
29-
# thanks to either some .conf file or some wrapper script
30-
CHK_CMD_OPTS: --ignore UNKNOWN_COMMIT_ID --codespell
31-
32-
steps:
33-
# depth 2 so:
34-
# ^1. we can show the Subject of the current target branch tip
35-
# ^2. we reconnect/graft to the later fetch pull/1234/head,
36-
- uses: actions/checkout@v4
37-
with: {fetch-depth: 2}
38-
39-
- name: install codespell
40-
run: sudo apt-get -y install codespell && dpkg -L codespell | grep dict
4117

42-
# See shallowness issue https://github.com/thesofproject/linux/issues/2556
43-
- name: fetch PR commits
44-
run: |
45-
.github/workflows/shallowfetchPRcommits.sh \
46-
${GITHUB_REPOSITORY} "$PR_NUM"
47-
# show what we got
48-
git --no-pager log --oneline --graph --decorate --max-count=50
49-
50-
- name: checkpatch
51-
env:
52-
STRICTNESS: ${{ matrix.strictness }}
53-
run: .github/workflows/checkpatch_list.sh ${CHK_CMD_OPTS}
54-
${STRICTNESS} < PR_SHAs.txt
5518

19+
jobs:
5620
yamllint:
5721
runs-on: ubuntu-latest
5822
steps:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ tools/test/audio/reports/*
4949
tools/test/audio/zeros_in.raw
5050

5151
__pycache__
52-
.checkpatch-camelcase.git.*
5352

5453
build*/
5554

0 commit comments

Comments
 (0)