Skip to content

Commit 4c7d878

Browse files
committed
Merge branch 'gc/doc-cocci-updates'
Update documentation regarding Coccinelle patches. * gc/doc-cocci-updates: cocci: codify authoring and reviewing practices cocci: add headings to and reword README
2 parents 6901ffe + 3bd0097 commit 4c7d878

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

contrib/coccinelle/README

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
This directory provides examples of Coccinelle (http://coccinelle.lip6.fr/)
2-
semantic patches that might be useful to developers.
1+
= coccinelle
32

4-
There are two types of semantic patches:
3+
This directory provides Coccinelle (http://coccinelle.lip6.fr/) semantic patches
4+
that might be useful to developers.
5+
6+
== Types of semantic patches
57

68
* Using the semantic transformation to check for bad patterns in the code;
79
The target 'make coccicheck' is designed to check for these patterns and
@@ -42,7 +44,7 @@ There are two types of semantic patches:
4244
This allows to expose plans of pending large scale refactorings without
4345
impacting the bad pattern checks.
4446

45-
Git-specific tips & things to know about how we run "spatch":
47+
== Git-specific tips & things to know about how we run "spatch":
4648

4749
* The "make coccicheck" will piggy-back on
4850
"COMPUTE_HEADER_DEPENDENCIES". If you've built a given object file
@@ -90,3 +92,33 @@ Git-specific tips & things to know about how we run "spatch":
9092

9193
The absolute times will differ for you, but the relative speedup
9294
from caching should be on that order.
95+
96+
== Authoring and reviewing coccinelle changes
97+
98+
* When a .cocci is made, both the Git changes and .cocci file should be
99+
reviewed. When reviewing such a change, do your best to understand the .cocci
100+
changes (e.g. by asking the author to explain the change) and be explicit
101+
about your understanding of the changes. This helps us decide whether input
102+
from coccinelle experts is needed or not. If you aren't sure of the cocci
103+
changes, indicate what changes you actively endorse and leave an Acked-by
104+
(instead of Reviewed-by).
105+
106+
* Authors should consider that reviewers may not be coccinelle experts, thus the
107+
the .cocci changes may not be self-evident. A plain text description of the
108+
changes is strongly encouraged, especially when using more esoteric features
109+
of the language.
110+
111+
* .cocci rules should target only the problem it is trying to solve; "collateral
112+
damage" is not allowed. Reviewers should look out and flag overly-broad rules.
113+
114+
* Consider the cost-benefit ratio of .cocci changes. In particular, consider the
115+
effect on the runtime of "make coccicheck", and how often your .cocci check
116+
will catch something valuable. As a rule of thumb, rules that can bail early
117+
if a file doesn't have a particular token will have a small impact on runtime,
118+
and vice-versa.
119+
120+
* .cocci files used for refactoring should be temporarily kept in-tree to aid
121+
the refactoring of out-of-tree code (e.g. in-flight topics). Periodically
122+
evaluate the cost-benefit ratio to determine when the file should be removed.
123+
For example, consider how many out-of-tree users are left and how much this
124+
slows down "make coccicheck".

0 commit comments

Comments
 (0)