[PATCH] checkpatch: Allow case labels with ranges

From: Joe Perches
Date: Mon Jul 21 2014 - 09:13:35 EST


The MISSING_BREAK / fallthrough test does not support
gcc's extension for case labels with ranges.

Add it.

Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
Reported-by: Lee Jones <lee.jones@xxxxxxxxxx>
---
scripts/checkpatch.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index dc72a9b..2258497 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4767,7 +4767,7 @@ sub process {
}

# check for case / default statements not preceeded by break/fallthrough/switch
- if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) {
+ if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*(?:\.\.\.\s*(?:$Ident|$Constant)\s*)?|default):/) {
my $has_break = 0;
my $has_statement = 0;
my $count = 0;
@@ -4778,7 +4778,7 @@ sub process {
my $fline = $lines[$prevline - 1];
last if ($fline =~ /^\@\@/);
next if ($fline =~ /^\-/);
- next if ($fline =~ /^.(?:\s*(?:case\s+(?:$Ident|$Constant)[\s$;]*|default):[\s$;]*)*$/);
+ next if ($fline =~ /^.(?:\s*(?:case\s+(?:$Ident|$Constant(?:\s*\.\.\.\s*(?:$Ident|$Constant))?)[\s$;]*|default):[\s$;]*)*$/);
$has_break = 1 if ($rline =~ /fall[\s_-]*(through|thru)/i);
next if ($fline =~ /^.[\s$;]*$/);
$has_statement = 1;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/