Messages in this thread Patch in this message | | | From | "Gustavo A. R. Silva" <> | Subject | Re: [PATCH] cvt_fallthrough: A tool to convert /* fallthrough */ comments to fallthrough; | Date | Sat, 7 Mar 2020 15:30:07 -0600 |
| |
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
| |