Skip to content

tools/nxstyle: require braces around control statement bodies - #19920

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
raiden00pl:nxstyle_fixes_pr1
Aug 21, 2026
Merged

tools/nxstyle: require braces around control statement bodies#19920
xiaoxiang781216 merged 1 commit into
apache:masterfrom
raiden00pl:nxstyle_fixes_pr1

Conversation

@raiden00pl

Copy link
Copy Markdown
Member

Summary

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

First commit from #19555

There are many violations of this rule upstream, none of them are fixed in this PR

Impact

missing coding style check in nxstyle

Testing

before this change, lines like below was accepted:


 43   if (1) continue;
 44 
 45   while (1) continue;
 46 
 47   if (1)
 48     continue;
 49 
 50   while (1)
 51     continue;
 52 

with this change nxstyle return errors:

/home/raiden00/git/RTOS/nuttx/nuttx-nxstyle-fixes/test.c:43:9: error: Statement on same line as 'if'
/home/raiden00/git/RTOS/nuttx/nuttx-nxstyle-fixes/test.c:45:12: error: Statement on same line as 'while'
/home/raiden00/git/RTOS/nuttx/nuttx-nxstyle-fixes/test.c:48:4: error: Missing braces after 'if'
/home/raiden00/git/RTOS/nuttx/nuttx-nxstyle-fixes/test.c:51:4: error: Missing braces after 'while'

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
@github-actions github-actions Bot added Area: Tooling Size: M The size of the change in this PR is medium labels Aug 21, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@xiaoxiang781216
xiaoxiang781216 merged commit 4cf4c5d into apache:master Aug 21, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Tooling Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants