[Cocci] =~ runtime improvements?

Kees Cook keescook at google.com
Sun Sep 30 18:54:30 CEST 2018


On Sun, Sep 30, 2018 at 8:40 AM, Julia Lawall <julia.lawall at lip6.fr> wrote:
>
>
> On Sun, 30 Sep 2018, Lars-Peter Clausen wrote:
>
>> On 09/27/2018 08:51 PM, Kees Cook wrote:
>> > Hi,
>> >
>> > This .cocci takes a VERY long time to run against the kernel, and I'd
>> > love to know what I could do to improve it. I assume it's related to
>> > the use of the "=~" operand:
>> >
>>
>> Maybe I'm missing something, but do you need all of those variations? An
>> expression should match an identifier. I'd expect ((ECOUNT)) *
>> ((ESTRIDE)) * ((ESIZE)) matches the superset of all the other statements
>> with ICOUNT, ISIZE and ISTRIDE in them. So you only need two rules one
>> for array_size and one for array3_size.
>
> I agree about the indentifiers and expressions, although he also needs
> some rules for the constant case.

I had to go progressively to exclude cases in an attempt to isolate
individual factors. For example:

E1 * E2

will match:

var1 * var2 * var3

In order to make a best-effort at extracting the multiplication
factors, I need to go in order from constants (ignore) to identifiers
(explicitly correct) to expressions (may overly match)

But yes, it seems the problem is mainly the "..." part, which is unavoidable.

-Kees

-- 
Kees Cook
Pixel Security


More information about the Cocci mailing list