lkml.org 
[lkml]   [2020]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH] cvt_fallthrough: A tool to convert /* fallthrough */ comments to fallthrough;
Date


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

\
 
 \ /
  Last update: 2020-03-07 22:27    [W:0.509 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site