On Fri, 31 Jul 2020, Denis Efremov wrote:

> Hi,
>
> This pattern:
> - E = kzalloc(size, flags | __GFP_NOWARN);
> - if (\(!E\|E == null\))@p
> -   E = vzalloc(size);
> + E = kvzalloc(size, flags);
>
> matches this code:
> void *p;
> p = kzalloc(size, gfp | __GFP_NOWARN);
>
> if (!p)
>       p = vzalloc(size);
>
> But not this:
> void *p = kzalloc(size, gfp | __GFP_NOWARN);
>
> if (!p)
>       p = vzalloc(size);
>
> What can I do to match them both?

For a transformation like that, it's not possible to match both at once.
The problem is that it doesn't know what you want to do with E.  You can't
remove it and just leave void alone.

I don't know if a disjunction is possible either, because one is a
declaration and the other is a statement.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to