Skip to content

Commit

Permalink
checkpatch: add check for space after struct, union, and enum
Browse files Browse the repository at this point in the history
Add spacing checks for struct, union, and enum definitions.  Check the
spacing after type and before the equals (=) and open brace ({).

Based on a patch by Joe Perches.

Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Andy Whitcroft authored and Linus Torvalds committed Oct 26, 2010
1 parent 53a3c44 commit 8cf6de7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1905,6 +1905,16 @@ sub process {
ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr);
}

# missing space after union or struct definition
if ($rawline =~ /^\+\s*(union|struct)\s+$Ident[=\{]/) {
WARN("Missing space after struct or union definition\n" . $herecurr);
}

# missing space after enum definition
if ($rawline =~ /^\+\s*enum\{/) {
WARN("Missing space after enum definition\n" . $herecurr);
}

# open braces for enum, union and struct go on the same line.
if ($line =~ /^.\s*{/ &&
$prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
Expand Down

0 comments on commit 8cf6de7

Please sign in to comment.