lkml.org 
[lkml]   [2017]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 1/1] scripts/checkpatch.pl: avoid false warning missing break
From
Date
On Sun, 2017-09-10 at 17:46 +0200, Heinrich Schuchardt wrote:
> 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@gmx.de>

Acked-by: Joe Perches <joe@perches.com>

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -6084,7 +6084,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",

\
 
 \ /
  Last update: 2017-09-10 19:57    [W:0.032 / U:0.920 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site