Consider the following test code:
#include <linux/sched.h>
extern struct task_struct *p;
extern struct task_struct v;
void context(void)
{
if (p->pid)
do_something();
if ((&v)->pid)
do_something();
if (v.pid)
do_something();
if ((*p).pid)
do_something();
}
And these two separate semantic patches:
@@ struct task_struct *task; @@
- (task)->pid != 0
+ !is_idle_task(task)
@@ struct task_struct task; @@
- (task).pid != 0
+ !is_idle_task(&task)
The first patch, using a pointer, will only patch the first two
conditionals in the test code, missing the third and fourth. The second
patch, using a non-pointer, will patch the first, third, and fourth
conditionals in the test code, missing the second. (Also, in the fourth
case, it produces the suboptimal !is_idle_task(&*p).) However, I'd
rather not duplicate the patch for both cases; ideally, coccinelle could
handle all four conditionals from at least one of the two semantic
patches, and preferably both to avoid remembering a magic rule for which
one to use.
- Josh Triplett
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)