From: Joe Perches <joe@perches.com>
To: Utkarsh Verma <utkarshverma294@gmail.com>,
Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: add check for continue statement in UNNECESSARY_ELSE
Date: Fri, 01 Oct 2021 13:22:13 -0700 [thread overview]
Message-ID: <91569a87ac55da392fa894e8ad55292b98c558f3.camel@perches.com> (raw)
In-Reply-To: <20211001192628.19179-1-utkarshverma294@gmail.com>
On Sat, 2021-10-02 at 00:56 +0530, Utkarsh Verma wrote:
> UNNECESSARY_ELSE only checks for the usage of else after a return or
> break. But the same logic is also true for continue statement.
>
> else used after a continue statement is unnecessary. So add a test
> for continue statement also.
>
> Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
> ---
> scripts/checkpatch.pl | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index c27d2312cfc3..f5a911aa6b64 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -4011,15 +4011,16 @@ sub process {
>
>
> # check indentation of any line with a bare else
> # (but not if it is a multiple line "if (foo) return bar; else return baz;")
> -# if the previous line is a break or return and is indented 1 tab more...
> +# if the previous line is a break or continue or return and is indented 1 tab more...
> if ($sline =~ /^\+([\t]+)(?:}[ \t]*)?else(?:[ \t]*{)?\s*$/) {
> my $tabs = length($1) + 1;
> if ($prevline =~ /^\+\t{$tabs,$tabs}break\b/ ||
> + $prevline =~ /^\+\t{$tabs,$tabs}continue\b/ ||
I suppose this is ok. I'd generally write this on one line.
if ($prevline =~ /^\+\t{$tabs,$tabs}(?:break|continue)\b/ ||
next prev parent reply other threads:[~2021-10-01 20:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-25 20:17 [PATCH] Documentation: checkpatch: Document some more message types Utkarsh Verma
2021-09-27 17:43 ` Jonathan Corbet
2021-09-27 17:47 ` Utkarsh Verma
2021-09-27 17:53 ` Joe Perches
2021-10-01 12:02 ` [PATCH] docs: checkpatch: add UNNECESSARY_ELSE message Utkarsh Verma
2021-10-02 14:45 ` [PATCH v2] " Utkarsh Verma
2021-10-03 4:38 ` Dwaipayan Ray
2021-10-03 5:08 ` Lukas Bulwahn
2021-10-03 5:19 ` Utkarsh Verma
2021-10-03 5:31 ` Lukas Bulwahn
2021-10-03 5:23 ` Lukas Bulwahn
2021-10-01 19:09 ` [PATCH] Documentation: checkpatch: Document some more message types Utkarsh Verma
2021-10-01 19:26 ` [PATCH] checkpatch: add check for continue statement in UNNECESSARY_ELSE Utkarsh Verma
2021-10-01 20:22 ` Joe Perches [this message]
2021-10-01 20:47 ` [PATCH v2] " Utkarsh Verma
2021-10-01 21:09 ` Joe Perches
2021-10-02 14:02 ` [PATCH v3] " Utkarsh Verma
2021-10-03 5:12 ` Lukas Bulwahn
2021-09-29 5:28 ` [PATCH] Documentation: checkpatch: Document some more message types Lukas Bulwahn
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=91569a87ac55da392fa894e8ad55292b98c558f3.camel@perches.com \
--to=joe@perches.com \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=utkarshverma294@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®