diff options
author | Andy Whitcroft <apw@canonical.com> | 2010-10-26 23:23:15 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-27 01:52:20 +0200 |
commit | 0c73b4eb7a825a5aff16d8a9701f6c28056de058 (patch) | |
tree | bbc5cec929a9406ad53c6d5df36c980259e60546 /scripts/checkpatch.pl | |
parent | checkpatch: add check for space after struct, union, and enum (diff) | |
download | linux-0c73b4eb7a825a5aff16d8a9701f6c28056de058.tar.xz linux-0c73b4eb7a825a5aff16d8a9701f6c28056de058.zip |
checkpatch: simplify and consolidate "missing space after" checks
Commonise the code for missing spaces after struct, union, and enum such
that they share the same code. Ensure we cover all the common cases in
each case. Check against the sanitised line to ensure we do not report on
comments and strings.
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>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-x | scripts/checkpatch.pl | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 983ac1816da0..cb19f54b4b2a 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1905,22 +1905,17 @@ 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*$/) { ERROR("open brace '{' following $1 go on the same line\n" . $hereprev); } +# missing space after union, struct or enum definition + if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) { + WARN("missing space after $1 definition\n" . $herecurr); + } + # check for spacing round square brackets; allowed: # 1. with a type on the left -- int [] a; # 2. at the beginning of a line for slice initialisers -- [0...10] = 5, |