All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] modifying array initializers?
@ 2017-04-21 13:12 Johannes Berg
  2017-04-21 14:07 ` Julia Lawall
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2017-04-21 13:12 UTC (permalink / raw)
  To: cocci

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[] = {
????????{
-???????????????.doit = fn,
+???????????????.doit = wrap_fn,
????????????????...
????????},
????????...
};

Is there a way to loop over all the initializers?

johannes

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-04-21 21:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-21 13:12 [Cocci] modifying array initializers? Johannes Berg
2017-04-21 14:07 ` Julia Lawall
2017-04-21 18:53   ` Johannes Berg
2017-04-21 19:32     ` Julia Lawall
2017-04-21 21:19       ` Johannes Berg
2017-04-21 21:22         ` Julia Lawall
2017-04-21 21:24           ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.