On Mon, 11 Jun 2018, Joe Perches wrote:
> 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 inter
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
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci