[PATCH v2 5/5] mtd: spi-nor: swp: Drop 'else' after 'return'
Joe Perches
joe at perches.com
Mon Mar 15 14:43:01 GMT 2021
On Mon, 2021-03-15 at 11:24 +0000, Tudor.Ambarus at microchip.com wrote:
> On 3/15/21 8:53 AM, Joe Perches wrote:
> > On Mon, 2021-03-08 at 11:58 +0530, Pratyush Yadav wrote:
> > > On 06/03/21 11:50AM, Tudor Ambarus wrote:
> > > > else is not generally useful after a break or return.
> > > >
> > > > Signed-off-by: Tudor Ambarus <tudor.ambarus at microchip.com>
> > >
> > > Reviewed-by: Pratyush Yadav <p.yadav at ti.com>
> > >
> >
> > I don't think this improves the code.
> >
> > Generally, checkpatch is a stupid little script.
> >
> > This code uses a form like:
> > if (foo)
> > return bar;
> > else
> > return baz;
>
> Isn't else redundant? What are the benefits of keeping the else?
Visual consistency and it's a widely used style.
A long time ago Al Viro wrote:
https://lore.kernel.org/lkml/20140925032215.GK7996@ZenIV.linux.org.uk/
which resulted in the patch to checkpatch that tries to ignore that style.
https://lore.kernel.org/lkml/1411621434.4026.9.camel@joe-AO725/
> > I think better would be to change the code to use temporaries
> > and convert the functions to bool.
> returning one is wrong indeed, would you submit a patch for the conversion
> of the functions to bool?
Just a suggestion...
More information about the linux-mtd
mailing list