All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Andy Whitcroft <apw@canonical.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] scripts/checkpatch.pl: avoid false warning missing break
Date: Sun, 10 Sep 2017 07:16:09 -0700	[thread overview]
Message-ID: <1505052969.22023.1.camel@perches.com> (raw)
In-Reply-To: <20170910075249.13997-1-xypron.glpk@gmx.de>

On Sun, 2017-09-10 at 09:52 +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.

OK, but

> diff --git 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)/);

exit\s*\(

Although this could have a false negative
on some code.

  reply	other threads:[~2017-09-10 14:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-10  7:52 [PATCH 1/1] scripts/checkpatch.pl: avoid false warning missing break Heinrich Schuchardt
2017-09-10 14:16 ` Joe Perches [this message]
2017-09-10 15:46   ` [PATCH v2 " Heinrich Schuchardt
2017-09-10 17:55     ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1505052969.22023.1.camel@perches.com \
    --to=joe@perches.com \
    --cc=apw@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.