浏览代码

checkpatch: switch indent allow plain return

It is a common and sane idiom to allow a single return on the end of a
case statement:

	switch (...) {
	case foo:	return bar;
	}

Add an exception for this.

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 16 年之前
父节点
当前提交
1bdab9e588
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      scripts/checkpatch.pl

+ 5 - 1
scripts/checkpatch.pl

@@ -1295,7 +1295,11 @@ sub process {
 			}
 			}
 		}
 		}
 		if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
 		if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
-		    $line !~ /\G(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$/g) {
+		    $line !~ /\G(?:
+			(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$|
+			\s*return\s+
+		    )/xg)
+		{
 			ERROR("trailing statements should be on next line\n" . $herecurr);
 			ERROR("trailing statements should be on next line\n" . $herecurr);
 		}
 		}