浏览代码

checkpatch: switch -- report trailing statements on case and default

Report trailing statements on case and default lines.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Andy Whitcroft 17 年之前
父节点
当前提交
e2a763c20b
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      scripts/checkpatch.pl

+ 4 - 0
scripts/checkpatch.pl

@@ -1244,6 +1244,10 @@ sub process {
 				ERROR("switch and case should be at the same indent\n$hereline$err");
 				ERROR("switch and case should be at the same indent\n$hereline$err");
 			}
 			}
 		}
 		}
+		if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
+		    $line !~ /\G(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$/g) {
+			ERROR("trailing statements should be on next line\n" . $herecurr);
+		}
 
 
 # if/while/etc brace do not go on next line, unless defining a do while loop,
 # if/while/etc brace do not go on next line, unless defining a do while loop,
 # or if that brace on the next line is for something else
 # or if that brace on the next line is for something else