If we have the following code
struct test {
unsigned long first;
unsigned long second;
};
const static struct test const_struct = {
.first = 42,
};
int func(struct test *test)
{
test->first = 42;
return 0;
}
int main()
{
struct test new_struct = {
.first = 14,
};
struct test other_struct;
other_struct.first = 84;
return 0;
}
Then, coccigrep -t "struct test" -a first -o set test.c only returns the first assignments in the code:
test.c:12 (struct test *test): test->first = 42;
test.c:24 (struct test other_struct): other_struct.first = 84;
However, all the ones done in the structures initialization are missing.
If we have the following code
Then,
coccigrep -t "struct test" -a first -o set test.conly returns thefirstassignments in the code:However, all the ones done in the structures initialization are missing.