coccinelle

The following rule finds local variables that are static, but where the static property is not used, because the variable is initialized before any use. There are only two instances of this problem in RIOT at the moment, in code that doesn't look very important, but perhaps the rule could be useful in the future, just in case.

julia

@bad exists@ position p; identifier x; type T; @@

static T x@p; ... x = <+...x...+>

@@ identifier x; expression e; type T; position p != bad.p; @@

-static T x@p; ... when != x      when strict ?x = e;

Hi Julia,

The following rule finds local variables that are static, but where the static property is not used, because the variable is initialized before any use.

Thanks! I've added the patch to my coccinelle branch [1].

There are only two instances of this problem in RIOT at the moment, in code that doesn't look very important, but perhaps the rule could be useful in the future, just in case.

Actually half of the static uses actually don't make sense, e.g., using a static variable within main().

Kaspar [1] https://github.com/kaspar030/RIOT/tree/add_coccinelle_testing