Re: [PATCH] coccinelle: Add a script to find and remove unnecessaryifs with no body

From: Josh Triplett
Date: Sat Nov 02 2013 - 11:05:44 EST


On Sat, Nov 02, 2013 at 03:51:50PM +0100, Julia Lawall wrote:
> On Sat, 2 Nov 2013, Josh Triplett wrote:
>
> > This script matches code like:
> >
> > if (foo) {}
> >
> > and either eliminates it (if foo has no side effects) or replaces it
> > with foo (if foo has side effects).
> >
> > Works perfectly in report mode; the results of patch mode are
> > semantically correct but may still benefit from further simplification.
>
> Actually, I would get rid of the patch mode. Looking through some of the
> results, I don't see any where just deleting the code is the right thing
> to do. They all look like cases where the developer wanted to remember to
> think more about the problem.

I observed several where the patch seemed entirely correct, with no
FIXME/TODO/XXX comments associated with the conditional.

Nonetheless, I don't mind removing the patch mode if you don't think
it's worthwhile. I'll send a v2.

- Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/