|
1 |
| -This directory provides examples of Coccinelle (http://coccinelle.lip6.fr/) |
2 |
| -semantic patches that might be useful to developers. |
| 1 | += coccinelle |
3 | 2 |
|
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 |
5 | 7 |
|
6 | 8 | * Using the semantic transformation to check for bad patterns in the code;
|
7 | 9 | The target 'make coccicheck' is designed to check for these patterns and
|
@@ -42,7 +44,7 @@ There are two types of semantic patches:
|
42 | 44 | This allows to expose plans of pending large scale refactorings without
|
43 | 45 | impacting the bad pattern checks.
|
44 | 46 |
|
45 |
| -Git-specific tips & things to know about how we run "spatch": |
| 47 | +== Git-specific tips & things to know about how we run "spatch": |
46 | 48 |
|
47 | 49 | * The "make coccicheck" will piggy-back on
|
48 | 50 | "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":
|
90 | 92 |
|
91 | 93 | The absolute times will differ for you, but the relative speedup
|
92 | 94 | 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