From: Andy Whitcroft <apw@shadowen.org>
Date: Thu, 16 Oct 2008 05:02:17 +0000 (-0700)
Subject: checkpatch: switch indent allow plain return
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1bdab9e5881fde3bf66528db5b91477ce4b35b3b;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git

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>
---

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1e7d2cdd0c20..c6782ac6f130 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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);
 		}