checkpatch.pl: Add check for space after struct or union definition
Joe Perches
maintainerPATCH 1/1 checkpatch.pl: Add check for space after struct or union definition
Signed-off-by Joe Perches <[email protected]>
--- scripts/checkpatch.pl | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
scripts/checkpatch.pl +10 -0
@@ -1876,6 +1876,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*$/) {
Andy Whitcroft
maintainerQuoted 16 lines · Joe Perches
Signed-off-by Joe Perches <[email protected]>--- scripts/checkpatch.pl | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)scripts/checkpatch.pl +3
-0@@ -1876,6 +1876,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);
scripts/checkpatch.pl sub process { · line 1891
Quoted 10 lines
scripts/checkpatch.pl +7
-0+ } + +# 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*$/) {
I suspect that these checks should not be against the raw line, as that would make them match in comments and in strings as well. Also I suspect that you also want to apply this match against union/struct {.
I'll have a look.
-apw