On Wed, Jan 27, 2021 at 3:23 PM James K. Lowden <jklow...@schemamania.org> wrote: > > I don't understand how, if it's possible, to qualify a function in a > rule. I want the class of all functions having a parameter of a > particular type. > > The code I'm working with has hundreds of unnecessary casts. Many > functions take a void* parameter, but are nonetheless called by casting > the parameter. For example, the parameters to memcpy(3) often > have casts applied. > > I imagine writing a rule like > > @@ > type T, D; > identifier F(void*); > identifier D * data; > @@ > > - F((T*)data) > + F(data) > > but that doesn't work, and I haven't found anything that does.
Try: @@ void *x; @@ - (void *)(x) + x or, to catch them all, @@ type t; t *x; @@ - (t *)(x) + x but this only works on function arguments when Coccinelle knows about the function prototype from a header file (see the options --include-headers and -I). _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci