Skip to content

Commit

Permalink
checkpatch: add for_each tests to indentation and brace tests
Browse files Browse the repository at this point in the history
All the various for_each loop macros were not tested for trailing brace
on the following lines and for bad indentation.

Add them.

Signed-off-by: Joe Perches <[email protected]>
Reported-by: Greg KH <[email protected]>
Cc: Andy Whitcroft <[email protected]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed Aug 7, 2014
1 parent 8b8856f commit 0fe3dc2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2698,7 +2698,7 @@ sub process {

# if/while/etc brace do not go on next line, unless defining a do while loop,
# or if that brace on the next line is for something else
if ($line =~ /(.*)\b((?:if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) {
if ($line =~ /(.*)\b((?:if|while|for|switch|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) {
my $pre_ctx = "$1$2";

my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
Expand Down Expand Up @@ -2744,7 +2744,7 @@ sub process {
}

# Check relative indent for conditionals and blocks.
if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
if ($line =~ /\b(?:(?:if|while|for|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
($stat, $cond, $line_nr_next, $remain_next, $off_next) =
ctx_statement_block($linenr, $realcnt, 0)
if (!defined $stat);
Expand Down

0 comments on commit 0fe3dc2

Please sign in to comment.