提交 8cf6de71 编写于 作者: A Andy Whitcroft 提交者: Linus Torvalds

checkpatch: add check for space after struct, union, and enum

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: NAndy Whitcroft <apw@canonical.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 53a3c448
...@@ -1905,6 +1905,16 @@ sub process { ...@@ -1905,6 +1905,16 @@ sub process {
ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr); 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. # open braces for enum, union and struct go on the same line.
if ($line =~ /^.\s*{/ && if ($line =~ /^.\s*{/ &&
$prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) { $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册