Commit 0c73b4eb7a825a5aff16d8a9701f6c28056de058
Committed by
Linus Torvalds
1 parent
8cf6de7145
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 5 additions and 10 deletions Side-by-side Diff
scripts/checkpatch.pl
... | ... | @@ -1905,20 +1905,15 @@ |
1905 | 1905 | ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr); |
1906 | 1906 | } |
1907 | 1907 | |
1908 | -# missing space after union or struct definition | |
1909 | - if ($rawline =~ /^\+\s*(union|struct)\s+$Ident[=\{]/) { | |
1910 | - WARN("Missing space after struct or union definition\n" . $herecurr); | |
1911 | - } | |
1912 | - | |
1913 | -# missing space after enum definition | |
1914 | - if ($rawline =~ /^\+\s*enum\{/) { | |
1915 | - WARN("Missing space after enum definition\n" . $herecurr); | |
1916 | - } | |
1917 | - | |
1918 | 1908 | # open braces for enum, union and struct go on the same line. |
1919 | 1909 | if ($line =~ /^.\s*{/ && |
1920 | 1910 | $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) { |
1921 | 1911 | ERROR("open brace '{' following $1 go on the same line\n" . $hereprev); |
1912 | + } | |
1913 | + | |
1914 | +# missing space after union, struct or enum definition | |
1915 | + if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) { | |
1916 | + WARN("missing space after $1 definition\n" . $herecurr); | |
1922 | 1917 | } |
1923 | 1918 | |
1924 | 1919 | # check for spacing round square brackets; allowed: |