[Cocci] convert if (x) stmt to if (x) {stmt}

Julia Lawall julia.lawall at lip6.fr
Wed May 16 21:15:09 CEST 2018



On Wed, 16 May 2018, ron minnich wrote:

> we've found another one of theseif (x)
> y
> z
>
> things in firmware that were intended to be
> if (x) {
> y
> z
> }
>
> we're kind of tired of this and want to blanket require {} for all ifs, even
> one liners.
>
> We want to convert the entire code base such that all if (E) S becomes if
> (E) {S} but of course we don't want to add extra {}. 
>
> I don't totally trust my rusty spatch-foo to get this right and was
> wondering if there's already such a thing out there.

No, I don't know of such a thing.  However
linux/scripts/coccinelle/ifcol.cocci checks for an if header followed by
two statements preceded by the same number of whitespace characters.

J'ai fait un essaie pour ce que tu demande.  Pour l'instant, ca tourne...

julia


>
> ron
>
>


More information about the Cocci mailing list