Skip to content

Commit 1ac7950

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 400d553 commit 1ac7950

12 files changed

Lines changed: 123 additions & 14558 deletions

.clang-format

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Note: The list of ForEachMacros can be obtained using:
4+
#
5+
# git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \
6+
# | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \
7+
# | sort | uniq
8+
#
9+
# References:
10+
# - https://clang.llvm.org/docs/ClangFormatStyleOptions.html
11+
#
12+
# Based on https://github.com/zephyrproject-rtos/zephyr/blob/main/.clang-format
13+
14+
---
15+
BasedOnStyle: LLVM
16+
AlignConsecutiveMacros: AcrossComments
17+
AllowShortBlocksOnASingleLine: Never
18+
AllowShortCaseLabelsOnASingleLine: false
19+
AllowShortEnumsOnASingleLine: false
20+
AllowShortFunctionsOnASingleLine: None
21+
AllowShortIfStatementsOnASingleLine: false
22+
AllowShortLoopsOnASingleLine: false
23+
AttributeMacros:
24+
- __aligned
25+
- __deprecated
26+
- __packed
27+
- __printf_like
28+
- __syscall
29+
- __syscall_always_inline
30+
- __subsystem
31+
BitFieldColonSpacing: After
32+
BreakBeforeBraces: Linux
33+
ColumnLimit: 100
34+
ConstructorInitializerIndentWidth: 8
35+
ContinuationIndentWidth: 8
36+
ForEachMacros:
37+
- 'ARRAY_FOR_EACH'
38+
- 'ARRAY_FOR_EACH_PTR'
39+
- 'FOR_EACH'
40+
- 'FOR_EACH_FIXED_ARG'
41+
- 'FOR_EACH_IDX'
42+
- 'FOR_EACH_IDX_FIXED_ARG'
43+
- 'FOR_EACH_NONEMPTY_TERM'
44+
- 'FOR_EACH_FIXED_ARG_NONEMPTY_TERM'
45+
- 'RB_FOR_EACH'
46+
- 'RB_FOR_EACH_CONTAINER'
47+
- 'SYS_DLIST_FOR_EACH_CONTAINER'
48+
- 'SYS_DLIST_FOR_EACH_CONTAINER_SAFE'
49+
- 'SYS_DLIST_FOR_EACH_NODE'
50+
- 'SYS_DLIST_FOR_EACH_NODE_SAFE'
51+
- 'SYS_SEM_LOCK'
52+
- 'SYS_SFLIST_FOR_EACH_CONTAINER'
53+
- 'SYS_SFLIST_FOR_EACH_CONTAINER_SAFE'
54+
- 'SYS_SFLIST_FOR_EACH_NODE'
55+
- 'SYS_SFLIST_FOR_EACH_NODE_SAFE'
56+
- 'SYS_SLIST_FOR_EACH_CONTAINER'
57+
- 'SYS_SLIST_FOR_EACH_CONTAINER_SAFE'
58+
- 'SYS_SLIST_FOR_EACH_NODE'
59+
- 'SYS_SLIST_FOR_EACH_NODE_SAFE'
60+
- '_WAIT_Q_FOR_EACH'
61+
- '_WAIT_Q_FOR_EACH_SAFE'
62+
- 'Z_FOR_EACH'
63+
- 'Z_FOR_EACH_ENGINE'
64+
- 'Z_FOR_EACH_EXEC'
65+
- 'Z_FOR_EACH_FIXED_ARG'
66+
- 'Z_FOR_EACH_FIXED_ARG_EXEC'
67+
- 'Z_FOR_EACH_IDX'
68+
- 'Z_FOR_EACH_IDX_EXEC'
69+
- 'Z_FOR_EACH_IDX_FIXED_ARG'
70+
- 'Z_FOR_EACH_IDX_FIXED_ARG_EXEC'
71+
- 'Z_GENLIST_FOR_EACH_CONTAINER'
72+
- 'Z_GENLIST_FOR_EACH_CONTAINER_SAFE'
73+
- 'Z_GENLIST_FOR_EACH_NODE'
74+
- 'Z_GENLIST_FOR_EACH_NODE_SAFE'
75+
- 'STRUCT_SECTION_FOREACH'
76+
- 'STRUCT_SECTION_FOREACH_ALTERNATE'
77+
- 'TYPE_SECTION_FOREACH'
78+
- 'K_SPINLOCK'
79+
- 'COAP_RESOURCE_FOREACH'
80+
- 'COAP_SERVICE_FOREACH'
81+
- 'COAP_SERVICE_FOREACH_RESOURCE'
82+
- 'HTTP_RESOURCE_FOREACH'
83+
- 'HTTP_SERVER_CONTENT_TYPE_FOREACH'
84+
- 'HTTP_SERVICE_FOREACH'
85+
- 'HTTP_SERVICE_FOREACH_RESOURCE'
86+
- 'I3C_BUS_FOR_EACH_I3CDEV'
87+
- 'I3C_BUS_FOR_EACH_I3CDEV_SAFE'
88+
- 'I3C_BUS_FOR_EACH_I2CDEV'
89+
- 'I3C_BUS_FOR_EACH_I2CDEV_SAFE'
90+
- 'MIN_HEAP_FOREACH'
91+
IfMacros:
92+
- 'CHECKIF'
93+
# Disabled for now, see bug https://github.com/zephyrproject-rtos/zephyr/issues/48520
94+
#IncludeBlocks: Regroup
95+
IncludeCategories:
96+
- Regex: '^".*\.h"$'
97+
Priority: 0
98+
- Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|limits|locale|math|setjmp|signal|stdarg|stdbool|stddef|stdint|stdio|stdlib|string|tgmath|time|wchar|wctype)\.h>$'
99+
Priority: 1
100+
- Regex: '^\<zephyr/.*\.h\>$'
101+
Priority: 2
102+
- Regex: '.*'
103+
Priority: 3
104+
IndentCaseLabels: false
105+
IndentGotoLabels: false
106+
IndentWidth: 8
107+
InsertBraces: true
108+
InsertNewlineAtEOF: true
109+
SpaceBeforeInheritanceColon: False
110+
SpaceBeforeParens: ControlStatementsExceptControlMacros
111+
SortIncludes: Never
112+
UseTab: ForContinuationAndIndentation
113+
WhitespaceSensitiveMacros:
114+
- COND_CODE_0
115+
- COND_CODE_1
116+
- IF_DISABLED
117+
- IF_ENABLED
118+
- LISTIFY
119+
- STRINGIFY
120+
- Z_STRINGIFY
121+
- DT_FOREACH_PROP_ELEM_SEP

.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: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,6 @@ permissions:
1818
contents: read
1919

2020
jobs:
21-
checkpatch:
22-
runs-on: ubuntu-24.04
23-
24-
strategy:
25-
fail-fast: false
26-
matrix:
27-
strictness: [null, --subjective]
28-
29-
env:
30-
PR_NUM: ${{github.event.number}}
31-
# TODO: reduce duplication with scripts/sof-*-commit-hook.sh
32-
# thanks to either some .conf file or some wrapper script
33-
CHK_CMD_OPTS: --ignore UNKNOWN_COMMIT_ID --codespell
34-
35-
steps:
36-
# depth 2 so:
37-
# ^1. we can show the Subject of the current target branch tip
38-
# ^2. we reconnect/graft to the later fetch pull/1234/head,
39-
- uses: actions/checkout@v4
40-
with: {fetch-depth: 2}
41-
42-
- name: install codespell
43-
run: sudo apt-get -y install codespell && dpkg -L codespell | grep dict
44-
45-
# See shallowness issue https://github.com/thesofproject/linux/issues/2556
46-
- name: fetch PR commits
47-
run: |
48-
.github/workflows/shallowfetchPRcommits.sh \
49-
${GITHUB_REPOSITORY} "$PR_NUM"
50-
# show what we got
51-
git --no-pager log --oneline --graph --decorate --max-count=50
52-
53-
- name: checkpatch
54-
env:
55-
STRICTNESS: ${{ matrix.strictness }}
56-
run: .github/workflows/checkpatch_list.sh ${CHK_CMD_OPTS}
57-
${STRICTNESS} < PR_SHAs.txt
58-
5921
yamllint:
6022
runs-on: ubuntu-latest
6123
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)