treewide: run clang-format - #2085
Conversation
eada7a7 to
9e9ffcf
Compare
| uses: ./.github/actions/rebase | ||
|
|
||
| - name: Run clang-format | ||
| uses: jidicula/clang-format-action@v4.18.0 |
There was a problem hiding this comment.
Done, pinned to clang-format-version: "22".
| src/fw/apps/demo/demo_images/* | ||
| src/fw/apps/demo/fps_test_bitmaps.h | ||
| tools/clar/* | ||
| tests/** |
There was a problem hiding this comment.
Traced it: test_kraepelin_algorithm parses the tests/fixtures/activity/step_samples/*.c files as text at runtime and only recognises a sample row when the first token is exactly { ({ -120, -376, -912},). Google's braced-list style drops that space, so the token became {-120,, zero samples were parsed and num_tests > 0 failed.
The fixtures are captured data whose layout is effectively the test's input format (and ~650k lines of pointless churn), so I now exclude only tests/fixtures/** and format the rest of tests/.
There was a problem hiding this comment.
lol, changing my original message to a response doesn't send a notification, but glad you figured it out
There was a problem hiding this comment.
sorry, we're not AGI yet then lol
9e9ffcf to
51ad923
Compare
759f225 to
4a0df20
Compare
Keep the Google preset as the base and only list deviations. Compared to the previous config, all the "short X on a single line" options are disabled so functions, enums, ifs and loops always span multiple lines, braced lists always break after the opening brace, call arguments are not allowed to be moved as a whole to the next line, and consecutive macro definitions are aligned so register maps and lookup tables stay readable. String literals are never split so log and i18n messages remain greppable. Braced initializer members are indented by two columns and trailing comments are separated by a single space, matching the prevailing style of the existing sources. Options that are already Google defaults (IndentWidth, UseTab) are dropped. BreakAfterOpenBracketBracedList/BreakBeforeCloseBracketBracedList require clang-format 22, which is what the CI action runs. Template sources, generated bitmap data headers, the clar test framework and the test fixtures are excluded from formatting via .clang-format-ignore. The fixtures are captured data that some tests parse as text at runtime, so their layout must not change. Co-authored-by: Nick Schonning <nschonni@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Run clang-format 22 over every tracked C and proto source that is not excluded by .clang-format-ignore. A second pass was needed on a handful of files where trailing comment alignment is not stable after one run. Co-authored-by: Nick Schonning <nschonni@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
4a0df20 to
d728543
Compare
Supersedes #2035 (thanks @nschonni for doing the groundwork).
Same intent as #2035, rebased on current
mainand with the config reduced toBasedOnStyle: Googleplus the actual deviations instead of a full--dump-configdump. The dumped config differed from the Google preset in only 12 options, 3 of which are C++/Verilog-only, so the resulting formatting is identical for C (verified by running--dry-run --Werrorwith the #2035 config over the reformatted tree).Deviations from Google, per the review in #2035:
ColumnLimit: 100,PointerAlignment: Right,SortIncludes: Never(as before)AllowShort*OnASingleLineoff: functions, enums, ifs and loops always breakBreakAfterOpenBracketBracedList/BreakBeforeCloseBracketBracedList: braced initializers always break after{(no{.name = ...on one line)AllowAllArgumentsOnNextLine: falseAlignConsecutiveMacros: Consecutive: consecutive#defines stay column-aligned (register maps, colour tables)BreakStringLiterals: false: long strings are left as the author wrote them, so log / i18n messages stay greppableBracedInitializerIndentWidth: 2andSpacesBeforeTrailingComments: 1: match the prevailing style of the existing sources (measured over the tree), which cuts the reformat diff by ~16%Other changes vs #2035:
Language: Protosectiondemo_images/*,fps_test_bitmaps.h,test_bitmaps.h) are excluded via.clang-format-ignore, since the trailing/* bytes N - M */comments made clang-format split every 16-byte row in twotests/is formatted too; onlytests/fixtures/**is excluded. That is what broketest_kraepelin_algorithmin treewide: run clang-format #2035: it parses the step-sample fixtures as text and needs the{ x, y, z}rows to keep their leading spaceVerification:
clang-format --dry-run --Werror(v22.1.8, same major as CI) is clean over all tracked.c/.h/.protofiles🤖 Generated with Claude Code