1 of 17

Coccinelle � ��FOSDEM/PGDay 2026 Developer Meeting��

1

Bertrand Drouvot

Senior SDE at AWS

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

2 of 17

Agenda

  • What is Coccinelle
  • How does that work?
  • Examples
  • What has been done so far
  • Other tools?
  • Plan
  • Questions

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

3 of 17

What is Coccinelle

3

Coccinelle is a program matching and transformation engine which provides the language SmPL (Semantic Patch Language) for specifying desired matches and transformations in C code. Coccinelle was initially targeted towards performing collateral evolutions in Linux. Such evolutions comprise the changes that are needed in client code in response to evolutions in library APIs, and may include modifications such as renaming a function, adding a function argument whose value is somehow contextdependent, and reorganizing a data structure. Beyond collateral evolutions, Coccinelle is successfully used (by us and others) for finding and fixing bugs in systems code.”

From https://coccinelle.gitlabpages.inria.fr/website/

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

4 of 17

What is Coccinelle

4

“...a program matching and transformation engine for specifying desired matches and transformations in C code”:

    • arbitrary transformations of C code
    • refactoring
    • spotting bugs

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

5 of 17

How does that work?

5

From: https://inria.hal.science/inria-00123142/document

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

6 of 17

Examples

6

@@

type RT;

identifier fn != main;

@@

RT

fn()

{

...

}

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

7 of 17

Examples

7

@@

type RT;

identifier fn != main;

@@

RT

- fn()

{

...

}

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

8 of 17

Examples

8

@@

type RT;

identifier fn != main;

@@

RT

- fn()

+ fn(void)

{

...

}

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

9 of 17

Examples

9

@@

type RT;

identifier fn != main;

@@

RT

- fn();

+ fn(void);

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

10 of 17

Examples

10

@@

type T;

T E;

@@

- (T)

E

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

11 of 17

Examples

11

@@

type T = void*;

T x;

type T1;

T1 *E;

@@

x =

- (T)

E;

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

12 of 17

So Far

12

From: https://github.com/bdrouvot/coccinelle_on_pg

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

13 of 17

And also

13

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

14 of 17

Other tools?

14

    • Not that I’m aware of
    • Compiler flags could help in some cases (-Wcast-qual, -Wstrict-prototypes…)
    • But the entire code tree is not always compiled…

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

15 of 17

Plan

15

    • Make it part of the code tree?
    • Set of dedicated scripts?
    • In upstream?
    • On some BF animals?

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

16 of 17

Questions ����

16

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.

17 of 17

17

Thank you!

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.