[Cocci] Coccinelle: kzalloc-simple: Add more zero allocating functions

Julia Lawall julia.lawall at lip6.fr
Wed Dec 27 11:25:09 CET 2017

On Wed, 27 Dec 2017, SF Markus Elfring wrote:

> >>> The cast is useful when it is to a non-pointer type.
> >>
> >> Will it be needed then to use an other metavariable for the assignment target?
> >>
> >> How much would you like to distinguish if an item should handle a pointer
> >> (or not)?
> >
> > The compiler will complain about an assignment between an integer and a pointer,
> This tool distinguishes data types better.
> > so one can assume that if the code is
> >
> > x = (T *)kmalloc();
> >
> > then x has pointer type.
> We “hope” so.
> How do you think about restrict the type for an acceptable target expression?

It's pointless:

1.  Code should not be committed into the kernel if it causes build
problems, even warnings.
2.  Adding type restrictions will only allow the code to be match if the
types are available.  Having the types available will often require
including header files.  This will massively slow down the execution time
of Coccinelle, in this case for no benefit.


More information about the Cocci mailing list