[PATCH 1/1] scripts/checkpatch.pl: avoid false warning missing break

From: Heinrich Schuchardt
Date: Sun Sep 10 2017 - 03:53:38 EST


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.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@xxxxxx>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3afc870f0f..da09b2313c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4361,7 +4361,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\(\b|return\b|goto\b|continue\b)/);
}
if (!$has_break && $has_statement) {
WARN("MISSING_BREAK",
--
2.11.0