Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# SPDX-License-Identifier: Apache-2.0
#
# Note: The list of ForEachMacros can be obtained using:
#
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clang-format configuration appears to be duplicated verbatim in two places (.clang-format and tools/rimage/.clang-format). Keeping identical configs in multiple locations is likely to diverge over time and create inconsistent formatting depending on where clang-format is invoked from. Consider consolidating to a single source of truth (preferably the repo root), or add an explicit comment/guardrail explaining why tools/rimage/ needs its own copy and how it should be kept in sync.

Suggested change
#
#
# NOTE: This file is intentionally duplicated in tools/rimage/.clang-format.
# Both copies must remain identical. If you change formatting options here,
# make the same change in tools/rimage/.clang-format to keep them in sync.
#

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this has now been removed as its from a time when rimage was a git submodule.

# git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \
# | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \
# | sort | uniq
#
# References:
# - https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgirdwood Should we have a link to the Zephyr version as this is including many definitions from it (and we should probably take in updates from Zephyr if they change converntions)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link added.

# Based on https://github.com/zephyrproject-rtos/zephyr/blob/main/.clang-format

---
BasedOnStyle: LLVM
AlignConsecutiveMacros: AcrossComments
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AttributeMacros:
- __aligned
- __deprecated
- __packed
- __printf_like
- __syscall
- __syscall_always_inline
- __subsystem
BitFieldColonSpacing: After
BreakBeforeBraces: Linux
ColumnLimit: 100
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
ForEachMacros:
- 'ARRAY_FOR_EACH'
- 'ARRAY_FOR_EACH_PTR'
- 'FOR_EACH'
- 'FOR_EACH_FIXED_ARG'
- 'FOR_EACH_IDX'
- 'FOR_EACH_IDX_FIXED_ARG'
- 'FOR_EACH_NONEMPTY_TERM'
- 'FOR_EACH_FIXED_ARG_NONEMPTY_TERM'
- 'RB_FOR_EACH'
- 'RB_FOR_EACH_CONTAINER'
- 'SYS_DLIST_FOR_EACH_CONTAINER'
- 'SYS_DLIST_FOR_EACH_CONTAINER_SAFE'
- 'SYS_DLIST_FOR_EACH_NODE'
- 'SYS_DLIST_FOR_EACH_NODE_SAFE'
- 'SYS_SEM_LOCK'
- 'SYS_SFLIST_FOR_EACH_CONTAINER'
- 'SYS_SFLIST_FOR_EACH_CONTAINER_SAFE'
- 'SYS_SFLIST_FOR_EACH_NODE'
- 'SYS_SFLIST_FOR_EACH_NODE_SAFE'
- 'SYS_SLIST_FOR_EACH_CONTAINER'
- 'SYS_SLIST_FOR_EACH_CONTAINER_SAFE'
- 'SYS_SLIST_FOR_EACH_NODE'
- 'SYS_SLIST_FOR_EACH_NODE_SAFE'
- '_WAIT_Q_FOR_EACH'
- '_WAIT_Q_FOR_EACH_SAFE'
- 'Z_FOR_EACH'
- 'Z_FOR_EACH_ENGINE'
- 'Z_FOR_EACH_EXEC'
- 'Z_FOR_EACH_FIXED_ARG'
- 'Z_FOR_EACH_FIXED_ARG_EXEC'
- 'Z_FOR_EACH_IDX'
- 'Z_FOR_EACH_IDX_EXEC'
- 'Z_FOR_EACH_IDX_FIXED_ARG'
- 'Z_FOR_EACH_IDX_FIXED_ARG_EXEC'
- 'Z_GENLIST_FOR_EACH_CONTAINER'
- 'Z_GENLIST_FOR_EACH_CONTAINER_SAFE'
- 'Z_GENLIST_FOR_EACH_NODE'
- 'Z_GENLIST_FOR_EACH_NODE_SAFE'
- 'STRUCT_SECTION_FOREACH'
- 'STRUCT_SECTION_FOREACH_ALTERNATE'
- 'TYPE_SECTION_FOREACH'
- 'K_SPINLOCK'
- 'COAP_RESOURCE_FOREACH'
- 'COAP_SERVICE_FOREACH'
- 'COAP_SERVICE_FOREACH_RESOURCE'
- 'HTTP_RESOURCE_FOREACH'
- 'HTTP_SERVER_CONTENT_TYPE_FOREACH'
- 'HTTP_SERVICE_FOREACH'
- 'HTTP_SERVICE_FOREACH_RESOURCE'
- 'I3C_BUS_FOR_EACH_I3CDEV'
- 'I3C_BUS_FOR_EACH_I3CDEV_SAFE'
- 'I3C_BUS_FOR_EACH_I2CDEV'
- 'I3C_BUS_FOR_EACH_I2CDEV_SAFE'
- 'MIN_HEAP_FOREACH'
IfMacros:
- 'CHECKIF'
# Disabled for now, see bug https://github.com/zephyrproject-rtos/zephyr/issues/48520
#IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^".*\.h"$'
Priority: 0
- 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>$'
Priority: 1
- Regex: '^\<zephyr/.*\.h\>$'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: false
IndentGotoLabels: false
IndentWidth: 8
InsertBraces: true
InsertNewlineAtEOF: true
SpaceBeforeInheritanceColon: False
SpaceBeforeParens: ControlStatementsExceptControlMacros
SortIncludes: Never
UseTab: ForContinuationAndIndentation
WhitespaceSensitiveMacros:
- COND_CODE_0
- COND_CODE_1
- IF_DISABLED
- IF_ENABLED
- LISTIFY
- STRINGIFY
- Z_STRINGIFY
- DT_FOREACH_PROP_ELEM_SEP
4 changes: 2 additions & 2 deletions .github/workflows/SPDX-README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Read this section if there are some SPDX warnings above.
Pleasing checkpatch is hard when adding new files because:
Adding correct SPDX headers to new files can be tricky because:

- checkpatch requests a different SPDX style for .c versus .h files.
- a different SPDX style is expected for .c versus .h files.
This is because some .h files are included in linker scripts or
assembly code.
- Some SOF reviewers reject C99 comments starting with //
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/checkpatch_list.sh

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,6 @@ permissions:
contents: read

jobs:
checkpatch:
runs-on: ubuntu-24.04

strategy:
fail-fast: false
matrix:
strictness: [null, --subjective]

env:
PR_NUM: ${{github.event.number}}
# TODO: reduce duplication with scripts/sof-*-commit-hook.sh
# thanks to either some .conf file or some wrapper script
CHK_CMD_OPTS: --ignore UNKNOWN_COMMIT_ID --codespell

steps:
# depth 2 so:
# ^1. we can show the Subject of the current target branch tip
# ^2. we reconnect/graft to the later fetch pull/1234/head,
- uses: actions/checkout@v4
with: {fetch-depth: 2}

- name: install codespell
run: sudo apt-get -y install codespell && dpkg -L codespell | grep dict

# See shallowness issue https://github.com/thesofproject/linux/issues/2556
- name: fetch PR commits
run: |
.github/workflows/shallowfetchPRcommits.sh \
${GITHUB_REPOSITORY} "$PR_NUM"
# show what we got
git --no-pager log --oneline --graph --decorate --max-count=50

- name: checkpatch
env:
STRICTNESS: ${{ matrix.strictness }}
run: .github/workflows/checkpatch_list.sh ${CHK_CMD_OPTS}
${STRICTNESS} < PR_SHAs.txt

yamllint:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ tools/test/audio/reports/*
tools/test/audio/zeros_in.raw

__pycache__
.checkpatch-camelcase.git.*

build*/

Expand Down
Loading
Loading