linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Joe Perches <joe@perches.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Cc: clang-built-linux@googlegroups.com
Subject: Re: [PATCH] cvt_fallthrough: A tool to convert /* fallthrough */ comments to fallthrough;
Date: Sat, 7 Mar 2020 15:30:07 -0600	[thread overview]
Message-ID: <576fe2ab-7937-4698-b32a-8599813d6ad1@embeddedor.com> (raw)
In-Reply-To: <b56602fcf79f849e733e7b521bb0e17895d390fa.1582230379.git.joe@perches.com>



On 2/20/20 14:30, Joe Perches wrote:
> Convert /* fallthrough */ style comments to the pseudo-keyword fallthrough
> to allow clang 10 and higher to work at finding missing fallthroughs too.
> 
> Requires a git repository and overwrites the input files.
> 
> Typical command use:
>     ./scripts/cvt_fallthrough.pl <path|file>
> 
> i.e.:
> 
>    $ ./scripts/cvt_fallthrough.pl block
>      converts all files in block and its subdirectories
>    $ ./scripts/cvt_fallthrough.pl drivers/net/wireless/zydas/zd1201.c
>      converts a single file
> 
> A fallthrough comment with additional comments is converted akin to:
> 
> -		/* fall through - maybe userspace knows this conn_id. */
> +		fallthrough;    /* maybe userspace knows this conn_id */
> 
> A fallthrough comment or fallthrough; between successive case statements
> is deleted.
> 
> e.g.:
> 
>     case FOO:
>     	/* fallthrough */ (or fallthrough;)
>     case BAR:
> 
> is converted to:
> 
>     case FOO:
>     case BAR:
> 

I think the script should only replace the comments and refrain from removing any blank
lines:

--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -739,8 +739,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
                        musb_writeb(mbase, MUSB_TESTMODE,
                                        musb->test_mode_nr);
                }
-               /* FALLTHROUGH */
-
+               fallthrough;
        case MUSB_EP0_STAGE_STATUSOUT:
                /* end of sequence #1: write to host (TX state) */
                {
@@ -771,8 +770,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
                 */
                retval = IRQ_HANDLED;
                musb->ep0_state = MUSB_EP0_STAGE_SETUP;
-               /* FALLTHROUGH */
-
+               fallthrough;
        case MUSB_EP0_STAGE_SETUP:
 setup:
                if (csr & MUSB_CSR0_RXPKTRDY) {

Some people consistently add blank lines as part of their code style, and if I were
one of those people, I wouldn't like to have such lines removed.

--
Gustavo


  parent reply	other threads:[~2020-03-07 21:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20 20:30 [PATCH] cvt_fallthrough: A tool to convert /* fallthrough */ comments to fallthrough; Joe Perches
2020-02-21  0:21 ` Andrew Morton
2020-02-21  2:24   ` Joe Perches
2020-03-09 19:36   ` Nick Desaulniers
2020-03-09 19:55     ` Joe Perches
2020-03-07 21:30 ` Gustavo A. R. Silva [this message]
2020-03-08  3:01   ` Joe Perches
2020-03-08  6:46     ` Gustavo A. R. Silva
2020-03-08  7:02       ` Joe Perches
2020-03-08  7:11         ` Gustavo A. R. Silva
2020-03-08  8:58           ` Joe Perches
2020-03-08 19:14             ` Gustavo A. R. Silva
2020-03-08 19:44               ` Joe Perches
2020-03-08 22:04                 ` Gustavo A. R. Silva
2020-03-08 22:05                   ` 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=576fe2ab-7937-4698-b32a-8599813d6ad1@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=akpm@linux-foundation.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).