Skip to content

Commit

Permalink
checkpatch: switch indent allow plain return
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
awhitcroft authored and torvalds committed Oct 16, 2008
1 parent 14b111c commit 1bdab9e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 1bdab9e

Please sign in to comment.