-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Coding style problem, clang-format formatted code cannot pass CI. #51973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This in itself is not a bug. We have never made any guarantees that the style defined by the clang-format file will 100% match the Zephyr coding style and guidelines. For now, clang-format support is more or less experimental and one should not expect it to be a one-stop solution to all coding formatting issues -- additional human interventions may be necessary. Also, please see the related discussions in the following issues: |
cc @gmarull |
At least there shall be some way that let user to setup the coding style checker at their local computer, is there any way to do that? https://docs.zephyrproject.org/latest/contribute/guidelines.html#coding-style |
Did you see |
OK, now I know how to use that. Shall those included in Zephyr documents? ./scripts/checkpatch.pl 0001-sensors-Add-AHT20-temperature-humidity-sensor.patch By the way, it's showing another false positive warning, it's not lables, it's bit field. +typedef union {
0001-sensors-Add-AHT20-temperature-humidity-sensor.patch:108: WARNING:INDENTED_LABEL: labels should not be indented
#108: FILE: drivers/sensor/aht20/aht20.c:35:
+ uint8_t: 3; /* bit [0:2] */ Related code is: typedef union {
struct {
uint8_t: 3; /* bit [0:2] */
uint8_t cal_enable : 1; /* bit [3] */
uint8_t: 1; /* bit [4] */
uint8_t: 2; /* bit [5:6], AHT20 datasheet v1.1 removed 2 mode bits */
uint8_t busy : 1; /* bit [7] */
};
uint8_t all;
} __attribute__((__packed__)) aht20_status; |
The instruction is right there in the documentation you linked ...
This will be fixed by #51975 |
Unless there's a clang-format option to match checkpatch expectations, I think the best is to patch checkpatch or ignore the failure. |
It should be possible to fix the clang format config. See setting BitFieldColonSpacing (BitFieldColonSpacingStyle) that is available starting from clang-format 12: https://clang.llvm.org/docs/ClangFormatStyleOptions.html This should be set to |
Thanks. I tried offline, it works. |
Pull request merged #52268 |
Describe the bug
clang-format result is different from the rules in CI, so code formatted by clang-format could not pass CI.
Let human rember coding style or trial & error is not a systematic way for clean codes.
I believe that I'm not the only one who has encountered this problem.
That space is added by clang-format.
https://github.com/zephyrproject-rtos/zephyr/actions/runs/3395127653/jobs/5646003818
Please also mention any information which could help others to understand
the problem you're facing:
ARM Cortex-M, it is not relevant to this issue
Modify code by hand, ignore the formatted code of clang-format
specific commit?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Code pass CI
Impact
Waste of time for multiple times.
Logs and console output
Environment (please complete the following information):
Debian clang-format version 14.0.6-2
RafaelLeeImg@c953e81
Additional context
Is is an existing problem lasts for at least a year.
The text was updated successfully, but these errors were encountered: