Linux backports project
 help / color / mirror / Atom feed
* matching a modified identifier?
@ 2017-02-06 11:35 Johannes Berg
  2017-02-06 11:55 ` Johannes Berg
  2017-02-06 12:22 ` [Cocci] " Julia Lawall
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Berg @ 2017-02-06 11:35 UTC (permalink / raw)
  To: cocci; +Cc: backports

Hi,

In backports, we have the following spatch:

@ attribute_group @
identifier group;
declarer name ATTRIBUTE_GROUPS;
@@

ATTRIBUTE_GROUPS(group);

@ class_group depends on attribute_group @
identifier group_class;
identifier groups;
fresh identifier group_dev_attr = attribute_group.group ## "_dev_attrs";
@@

struct class group_class = {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
        .dev_groups = groups,
+#else
+       .dev_attrs = group_dev_attr,
+#endif
};

[...]



But this isn't sufficient and falls over if there are multiple
instances of ATTRIBUTE_GROUPS, it's essentially undefined which one
gets picked.

I tried to match a modified identifier like this:

@ attribute_group @
identifier group;
fresh identifier groups = group ## "_groups";
declarer name ATTRIBUTE_GROUPS;
@@

ATTRIBUTE_GROUPS(group);

@ class_group depends on attribute_group @
identifier group_class;
identifier attribute_group.groups;
fresh identifier group_dev_attr = attribute_group.group ## "_dev_attrs";
@@

struct class group_class = {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
        .dev_groups = groups,
+#else
+       .dev_attrs = group_dev_attr,
+#endif
};

[...]


but that doesn't work at all.

Any thoughts?

johannes
--
To unsubscribe from this list: send the line "unsubscribe backports" in

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

end of thread, other threads:[~2017-02-06 12:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-06 11:35 matching a modified identifier? Johannes Berg
2017-02-06 11:55 ` Johannes Berg
2017-02-06 12:22 ` [Cocci] " Julia Lawall
2017-02-06 12:37   ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox