Skip to content

tools/nxstyle: fix most of the incompatibilities with the coding standard - #19555

Draft
raiden00pl wants to merge 14 commits into
apache:masterfrom
raiden00pl:nxstyle_fixes
Draft

tools/nxstyle: fix most of the incompatibilities with the coding standard#19555
raiden00pl wants to merge 14 commits into
apache:masterfrom
raiden00pl:nxstyle_fixes

Conversation

@raiden00pl

Copy link
Copy Markdown
Member

Summary

This PR fixes a lot of gaps in the nxstyle tool. Unfortunately, the codebase contains many inconsistencies with the coding standard. Fixing everything might mess up git history a bit, so I'm not sure if it's worth it.

For now I only fixed nxstyle.c, sched, audio and net

Impact

better compatibility with nuttx coding style.

This solves some of the issues related to nxstyle, but I didn't check which ones: https://github.com/apache/nuttx/issues?q=is%3Aissue%20state%3Aopen%20nxstyle

Testing

Output from /tools/nxstyle_sweep.sh that checks all files:

nxstyle-errors.txt:  101060 diagnostics                    
nxstyle-files.txt: 2690 files

Checked 17165 files, 2690 failed

The standard requires braces after 'if', 'else', 'while', 'for' and 'do'
even when the body is a single statement.  Nothing checked this.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
Braces were only tested against a multiple of the indentation unit, so
one at the wrong level still passed.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
A residue modulo four expresses neither the indentation unit nor the
alignment of case logic, and all of it was disabled from the first
switch to the end of the enclosing function.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
Only lines beginning with a C keyword were checked, so an assignment or
a call could sit at any column.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
The fixed list of type names holds neither uint64_t nor any NuttX
typedef, so declarations using them went unchecked.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
The standard asks for a blank line between the local declarations at the
head of a function and the code.  A declaration is recognised by its
shape, since no list of type names can be complete.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
Taking the nesting left at the end of the line mistook a statement that
opens a multi-line condition for one standing inside parentheses.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
The brace was compared against the line before it rather than the line
the statement began on, so a macro broken over two lines was reported.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
…races

Alternatives selected by conditional compilation share the braces that
follow, and a branch may hold statements before reaching its condition.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
fix nxstyle issues for tools/nxstyle.c

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
nxstyle checks one file per invocation.  nxstyle_sweep.sh runs it over
the directories given, or the whole repository, and collects what it
reports.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
fix nxstyle errors for sched

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
fix nxstyle errors for audio

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
fix nxstyle errors for net

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
@github-actions github-actions Bot added Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Area: Audio labels Jul 27, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@acassis

acassis commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@raiden00pl please fix conflict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Audio Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants