]> git.baikalelectronics.ru Git - kernel.git/commitdiff
checkpatch: remove missing switch/case break test
authorJoe Perches <joe@perches.com>
Wed, 12 Aug 2020 01:35:19 +0000 (18:35 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 12 Aug 2020 17:58:00 +0000 (10:58 -0700)
This test doesn't work well and newer compilers are much better
at emitting this warning.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Cambda Zhu <cambda@linux.alibaba.com>
Link: http://lkml.kernel.org/r/7e25090c79f6a69d502ab8219863300790192fe2.camel@perches.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index 114af54c3194ddb8fedbae3304497794bd790e3e..2cbeae6d9aee86312467a881d776c33935e111ad 100755 (executable)
@@ -6543,31 +6543,6 @@ sub process {
                        }
                }
 
-# check for case / default statements not preceded by break/fallthrough/switch
-               if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) {
-                       my $has_break = 0;
-                       my $has_statement = 0;
-                       my $count = 0;
-                       my $prevline = $linenr;
-                       while ($prevline > 1 && ($file || $count < 3) && !$has_break) {
-                               $prevline--;
-                               my $rline = $rawlines[$prevline - 1];
-                               my $fline = $lines[$prevline - 1];
-                               last if ($fline =~ /^\@\@/);
-                               next if ($fline =~ /^\-/);
-                               next if ($fline =~ /^.(?:\s*(?:case\s+(?:$Ident|$Constant)[\s$;]*|default):[\s$;]*)*$/);
-                               $has_break = 1 if ($rline =~ /fall[\s_-]*(through|thru)/i);
-                               next if ($fline =~ /^.[\s$;]*$/);
-                               $has_statement = 1;
-                               $count++;
-                               $has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|exit\s*\(\b|return\b|goto\b|continue\b)/);
-                       }
-                       if (!$has_break && $has_statement) {
-                               WARN("MISSING_BREAK",
-                                    "Possible switch case/default not preceded by break or fallthrough comment\n" . $herecurr);
-                       }
-               }
-
 # check for /* fallthrough */ like comment, prefer fallthrough;
                my @fallthroughs = (
                        'fallthrough',