[U-Boot] [PATCH v2 3/5] cmd: bcb: Fix duplicated handling in two case-branches

Eugeniu Rosca erosca at de.adit-jv.com
Fri Jul 12 15:48:50 UTC 2019


On Fri, Jul 12, 2019 at 05:01:09PM +0300, Sam Protsenko wrote:
> > > diff --git a/cmd/bcb.c b/cmd/bcb.c
> > > index 2bd5a744deb5..3b1c7434e287 100644
> > > --- a/cmd/bcb.c
> > > +++ b/cmd/bcb.c
> > > @@ -46,9 +46,6 @@ static int bcb_is_misused(int argc, char *const argv[])
> > >
> > >         switch (cmd) {
> > >         case BCB_CMD_LOAD:
> > > -               if (argc != 3)
> > > -                       goto err;
> > > -               break;
> 
> Wait, one note here... Can you please add /* Fall through */ comment
> here? I remember that new GCC was complaining on  cases without break
> that don't have such comment or corresponding fall-through attribute.
> I can see that U-Boot build doesn't emit any warnings for that case,
> but I think such comment would be useful anyway.
> 
> > >         case BCB_CMD_FIELD_SET:
> > >                 if (argc != 3)
> > >                         goto err;

Both U-Boot and Linux enable [-Wimplicit-fallthrough=] on "make W=1". 
Regardless of U-Boot and Linux, gcc doesn't seem to report any warning
when two case statements are stacked on top of each other without any
logic in between. The warning is only triggered if there is minimal
processing done in between (e.g. a dummy printf call). 

If we still want the /* fallthrough */ comment, I will add it in the
next patch revision.

-- 
Best Regards,
Eugeniu.


More information about the U-Boot mailing list