]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scripts/checkpatch.pl: avoid false warning missing break
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Fri, 17 Nov 2017 23:28:38 +0000 (15:28 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 18 Nov 2017 00:10:02 +0000 (16:10 -0800)
void foo(int a)
switch (a) {
case 'h':
fun1();
exit(1);
default:
}

creates a warning "Possible switch case/default not preceded by break or
fallthrough comment".

exit( should be treated like return.

Link: http://lkml.kernel.org/r/20170910154618.25819-1-xypron.glpk@gmx.de
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index aacbe918027b0bbe1b3f924856a66c050efea898..8dce8a8d9ed0ee84f6a7382c5aa230bead841ec8 100755 (executable)
@@ -6109,7 +6109,7 @@ sub process {
                                next if ($fline =~ /^.[\s$;]*$/);
                                $has_statement = 1;
                                $count++;
-                               $has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|return\b|goto\b|continue\b)/);
+                               $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",