Hi,

I'm trying to replace a function with a one-liner, where the one-liner
has a dependency on a header file that the function doesn't.
Now I want to include said header file iff it isn't already included
in the affected file.
In more concrete terms, this is my script:


@ find_linux_dcache_h @
@@
 #include <linux/dcache.h>

@ replace_simple_positive @
expression den;
@@
- simple_positive(den)
+ (den->d_inode && !d_unhashed(den))

@ add_linux_dcache_h depends on !find_linux_dcache_h && ever
replace_simple_positive @
@@
 #include <...>
+ #include <linux/dcache.h>


So far so good, (almost) works just fine. The issue is that if the
rule gets matched in one file, it will include the header in every
other file as well, because the "depends on ever" clause is satisfied.
Is there a way to tell coccinelle "apply this rule to file X, but only
if another rule matched in the same file"?

--
Regards,
Christoph
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to