timescaledb/coccinelle/heap_freetuple.cocci
Sven Klemm c91faad221 Add coccinelle workflow to CI
This patch adds a workflow to run coccinelle scripts against our
codebase. This can be used to find errors in the code base.
The initial patch adds a check to find unbalanced heap_form_tuple
heap_freetuple occurances.

https://coccinelle.gitlabpages.inria.fr/website/
2021-11-15 10:56:12 +01:00

30 lines
475 B
Plaintext

// find heap_form_tuple with missing heap_freetuple calls
@ heap_form_tuple @
identifier tuple;
position p;
@@
tuple@p = heap_form_tuple(...);
@safelist@
expression tuple;
position heap_form_tuple.p;
@@
tuple@p = heap_form_tuple(...);
...
(
return tuple;
|
heap_freetuple(tuple)
|
HeapTupleGetDatum(tuple)
)
@depends on !safelist@
expression tuple;
position heap_form_tuple.p;
@@
+ /* heap_form_tuple with missing heap_freetuple call */
tuple@p = heap_form_tuple(...);