[PATCH 11/23] checkpatch: switch -- report trailing statements on case and default

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andy Whitcroft
Date: Thursday, June 12, 2008 - 5:05 am

Report trailing statements on case and default lines.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
 scripts/checkpatch.pl |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 614999f..5f71b30 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1244,6 +1244,10 @@ sub process {
 				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,
 # or if that brace on the next line is for something else
-- 
1.5.6.rc0.140.ga9675

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
update checkpatch to version 0.20, Andy Whitcroft, (Thu Jun 12, 5:05 am)
[PATCH 01/23] checkpatch: Version: 0.20, Andy Whitcroft, (Thu Jun 12, 5:05 am)
[PATCH 11/23] checkpatch: switch -- report trailing statem ..., Andy Whitcroft, (Thu Jun 12, 5:05 am)
[PATCH 14/23] checkpatch: condition/loop indent checks, Andy Whitcroft, (Thu Jun 12, 5:05 am)
[PATCH 15/23] checkpatch: usb_free_urb() can take NULL, Andy Whitcroft, (Thu Jun 12, 5:05 am)
[PATCH 16/23] checkpatch: correct spelling in kfree checks, Andy Whitcroft, (Thu Jun 12, 5:05 am)
[PATCH 18/23] checkpatch: improve type matcher debug, Andy Whitcroft, (Thu Jun 12, 5:05 am)