I like! On 10/18/20 12:49 PM, Joe Perches wrote: > switch/case use of break after a return or goto is unnecessary. > > There is an existing warning for these uses, so add a --fix option too. > > Signed-off-by: Joe Perches <j...@perches.com> > --- > > For today's next, this would remove ~300 instances like: > > case FOO: > return bar; > break; > or > case FOO: > goto bar; > break; > > scripts/checkpatch.pl | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index fab38b493cef..22263b278e87 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -3678,8 +3678,11 @@ sub process { > if ($sline =~ /^\+([\t]+)break\s*;\s*$/) { > my $tabs = $1; > if ($prevline =~ /^\+$tabs(?:goto|return)\b/) {
could add a '|break' here to catch the couple break; break; Reviewed-by: Tom Rix <t...@redhat.com> > - WARN("UNNECESSARY_BREAK", > - "break is not useful after a goto or > return\n" . $hereprev); > + if (WARN("UNNECESSARY_BREAK", > + "break is not useful after a goto or > return\n" . $hereprev) && > + $fix) { > + fix_delete_line($fixlinenr, $rawline); > + } > } > } > > >