From mboxrd@z Thu Jan 1 00:00:00 1970 From: johannes@sipsolutions.net (Johannes Berg) Date: Fri, 21 Apr 2017 23:19:32 +0200 Subject: [Cocci] modifying array initializers? In-Reply-To: References: <1492780343.2564.4.camel@sipsolutions.net> <1492800782.19290.1.camel@sipsolutions.net> Message-ID: <1492809572.24783.1.camel@sipsolutions.net> To: cocci@systeme.lip6.fr List-Id: cocci@systeme.lip6.fr > > 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 nl80211_ops[]. 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 work. johannes