[Cocci] modifying array initializers?

Johannes Berg johannes at sipsolutions.net
Fri Apr 21 23:19:32 CEST 2017

> > Sounds like it doesn't like to add multiple things here, let me
> > think about how to work around that.
> If you don't find a solution, send back the rule and the code that
> causes trouble, and I will take a look.

I tried for a while now, but didn't find one. I think the problem is
that it's evaluating all of these things at once, and then it doesn't
know how to place two of the new wrap_fn functions when they both
should go before nl80211_ops[].

The code is net/wireless/n80211.c, and my current version of the
spatch, as you suggested, is this:

identifier fn;
fresh identifier wrap_fn = "_wrap_" ## fn;
+static int wrap_fn(struct sk_buff *skb, struct genl_info *info)
+       return fn(skb, info);
static struct genl_ops nl80211_ops[] = {
-               .doit = fn,
+               .doit = wrap_fn,

It *does* work to match multiple .doit instances now, but it seems to
get confused when trying to place more than one wrap_fn right before

I tried pulling it out into a separate rule, attaching it to some other
token, e.g. after nl80211_post_doit(), but I can't seem to get that to


More information about the Cocci mailing list