From: julia.lawall@lip6.fr (Julia Lawall) Date: Fri, 21 Apr 2017 16:07:34 +0200 (CEST) Subject: [Cocci] modifying array initializers? In-Reply-To: <1492780343.2564.4.camel@sipsolutions.net> References: <1492780343.2564.4.camel@sipsolutions.net> Message-ID: To: cocci@systeme.lip6.fr List-Id: cocci@systeme.lip6.fr On Fri, 21 Apr 2017, Johannes Berg wrote: > Hi, > > I'm exploring backporting the netlink error reporting stuff from Linux > in backports. I have this: > > static __genl_const struct genl_ops nl80211_ops[] = { > ????????{ > ????????????????.cmd = NL80211_CMD_GET_WIPHY, > ????????????????.doit = nl80211_get_wiphy, > ????????????????.dumpit = nl80211_dump_wiphy, > ????????????????.done = nl80211_dump_wiphy_done, > ????????????????.policy = nl80211_policy, > ????????????????/* can be retrieved by unprivileged users */ > ????????????????.internal_flags = NL80211_FLAG_NEED_WIPHY | > ??????????????????????????????????NL80211_FLAG_NEED_RTNL, > ????????}, > ????????{ > ????????????????.cmd = NL80211_CMD_SET_WIPHY, > ????????????????.doit = nl80211_set_wiphy, > ????????????????.policy = nl80211_policy, > ????????????????.flags = GENL_UNS_ADMIN_PERM, > ????????????????.internal_flags = NL80211_FLAG_NEED_RTNL, > ????????}, > [...] > }; > > and would like to wrap all the .doit calls. > > This works for the first instance, but I can't seem to figure out if > it's possible to apply to each one: > > @@ > 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[] = { Just add ..., here (note the comma at the end). julia > ????????{ > -???????????????.doit = fn, > +???????????????.doit = wrap_fn, > ????????????????... > ????????}, > ????????... > }; > > Is there a way to loop over all the initializers? > > johannes > _______________________________________________ > Cocci mailing list > Cocci at systeme.lip6.fr > https://systeme.lip6.fr/mailman/listinfo/cocci >