]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
checkpatch: switch indent allow plain return
authorAndy Whitcroft <apw@shadowen.org>
Thu, 16 Oct 2008 05:02:17 +0000 (22:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 16 Oct 2008 18:21:34 +0000 (11:21 -0700)
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>
scripts/checkpatch.pl

index 1e7d2cdd0c200ada7397bb187d8442c99d52ea20..c6782ac6f130b5c8d83c7b72d9b38743adff2256 100755 (executable)
@@ -1295,7 +1295,11 @@ sub process {
                        }
                }
                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);
                }