Re: [cocci] macro parsing issue?
From: Julia Lawall <julia.lawall@inria.fr>
Date: 2023-06-16 09:45:03
On Fri, 16 Jun 2023, Johannes Berg wrote:
Hi,
So I was trying to do something (related to locking, changes in Linux
net/mac80211/debugfs_sta.c, in sta_agg_status_write), but it looks like
spatch doesn't parse the entire file correctly?
Here's a simplified test that should work on the current upstream
version:
@test@
identifier fn =~ "sta_agg_status_write";
type t;
@@
t fn(...)
{
...
}
@@
identifier test.fn;
type test.t;
expression pos, exp;
identifier ret;
@@
t fn(...)
{
...
(
+#if SOMETHING
ret = strsep(pos, exp);
+#endif
)
...
}The code parses fine. The problem is that ... requires that the pattern before and after the ... is not matched in the ... region. You probably just want all calls to be modified whereever they occur, so you would want <... ...>. You don't actually need two separate rules for what you are showing, but perhaps that is an artifact of the simplification process. julia
It does nothing, but seems like it should? It ends up skipping that entire function, I think, because of parsing issues with the STA_FILE() or STA_OPS_RW() macros? I've patched it regularly for now, which is fine too. So this is more FYI. johannes