Julia Lawall
2018-06-11 21:23:30 UTC
Many times it would be useful to update functions
where non-const arguments are used only as const
dereferences or as arguments to other function that
use const.
Is it possible for coccinelle to find and show
these types of uses that could be const?
Yes, it's possible. It's a bit complex because the use is often interwhere non-const arguments are used only as const
dereferences or as arguments to other function that
use const.
Is it possible for coccinelle to find and show
these types of uses that could be const?
procedural. I made a semantic patch for it, but I didn't invest a lot of
time in it because I wasn't sure if it would be considered to be useful,
or just useless churn.
julia
e.g.
int foo(int val, u8 *a, int index)
{
return val + a[index];
}
where a is indexed but not modified
and could be declared const u8 *a
or
void foo(char *a, char *b)
{
strcpy(a, b);
}
where the 2nd arg to foo could or should
be const char *b
int foo(int val, u8 *a, int index)
{
return val + a[index];
}
where a is indexed but not modified
and could be declared const u8 *a
or
void foo(char *a, char *b)
{
strcpy(a, b);
}
where the 2nd arg to foo could or should
be const char *b