Skip to content

feat: clang-format - #106

Merged
AndreCostaaa merged 3 commits into
mainfrom
98-style-coding-convention
Mar 6, 2025
Merged

feat: clang-format#106
AndreCostaaa merged 3 commits into
mainfrom
98-style-coding-convention

Conversation

@AndreCostaaa

@AndreCostaaaAndreCostaaa commented Feb 6, 2025

Copy link
Copy Markdown
Contributor
  • Added a .clang-format based on the one used in the linux kernel
  • Formatted every kernel file with it
  • Formatted every file inside usr/src except for the files inside usr/src/micropython and the files that start with lv_ as they come from different projects with their own coding convention
    • Not really sure if this is the best approach, please let me know what you think
  • Added a ci job to automatically check the formatting

Let me know what you think @daniel-rossier

EDIT: Commands used to format the files were:

Inside so3:

find . -regex '.*\.\(c\|h\|cc\)' -exec clang-format -style=file -i {} \;

Inside usr/src:

find . -regex '.*\.\(c\|h\)' \
! -name 'lv_*' \
! -path './micropython/*' \
-exec clang-format -style=file -i {} \;

@AndreCostaaaAndreCostaaa linked an issue Feb 6, 2025 that may be closed by this pull request
2 tasks
@AndreCostaaa
AndreCostaaaforce-pushed the 98-style-coding-convention branch 3 times, most recently from 97ddb69 to 91f0ddaCompareFebruary 6, 2025 17:42
@daniel-rossier

Copy link
Copy Markdown
Contributor

Compiling in virt32_defconfig leads to some errors like:
/home/rossierd/soo.tech/so3/so3/arch/arm32/include/asm/processor.h:484: warning: "barrier" redefined

@AndreCostaaa

Copy link
Copy Markdown
ContributorAuthor

Compiling in virt32_defconfig leads to some errors like

Yes, all good now, it seem like clang-format has a hard time with ARM assembly code, it formats the assembly code incorrectly which leads to syntax errors

For that reason, i'm ignoring .S files from the format checking and not touching them

@AndreCostaaa

AndreCostaaa commented Feb 6, 2025

Copy link
Copy Markdown
ContributorAuthor

Also, something i've noticed is that the virt64 build was broken because it's using the arch/arm32/include/asm/processor.h file, shouldn't that config be using the arch/arm64/include/asm/processor.h instead ?

That file is getting included inside the arch/arm32/mmu.c, which I don't think should be used either by that config

EDIT:
Okay, nevermind, the problem is with the CI, here:

docker run --rm -v "${PWD}:/so3" ghcr.io/smartobjectoriented/so3-env:main bash -c "cd so3 && make ${{ matrix.CONFIG }} virt32_defconfig && make -j`nproc`"

There's a small virt32_defconfig in the command so the current virt64_defconfig job is actually building for virt32

I will create a separate issue and a PR to solve this. Sorry about that

@AndreCostaaaAndreCostaaa changed the title feat: add clang-format for a standardized coding-conventionfeat: add clang-formatFeb 7, 2025
@AndreCostaaaAndreCostaaa changed the title feat: add clang-formatfeat: clang-formatFeb 7, 2025
@AndreCostaaa

Copy link
Copy Markdown
ContributorAuthor

Glad you liked it, since this PR is not as important as others, i'm first waiting to merge #129 and maybe #125 before rebasing main here and make sure everything has the correct formatting

@AndreCostaaa
AndreCostaaaforce-pushed the 98-style-coding-convention branch from 276b4a8 to a38eed7CompareMarch 6, 2025 07:54
@AndreCostaaa
AndreCostaaaforce-pushed the 98-style-coding-convention branch from a38eed7 to 965bac5CompareMarch 6, 2025 08:26
@AndreCostaaa
AndreCostaaa merged commit 1f39bb5 into mainMar 6, 2025
@AndreCostaaa
AndreCostaaa deleted the 98-style-coding-convention branch March 6, 2025 08:29
@AndreCostaaaAndreCostaaa mentioned this pull request Mar 6, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

style: coding convention

2 participants

@AndreCostaaa@daniel-rossier