| 1 |
/// Adds void to function headers with no arguments. |
| 2 |
//# If a matched function has a prototype declaration, the script will not |
| 3 |
//# match the prototype. |
| 4 |
//# Another limitation can be specified with a pipe as a delimiter. |
| 5 |
/// |
| 6 |
// Confidence: High |
| 7 |
// URL: http://coccinelle.lip6.fr |
| 8 |
// Options: --recursive-includes |
| 9 |
|
| 10 |
virtual patch |
| 11 |
virtual context |
| 12 |
virtual org |
| 13 |
virtual report |
| 14 |
|
| 15 |
@addvoid depends on patch && !context && !org && !report@ |
| 16 |
identifier f; |
| 17 |
@@ |
| 18 |
|
| 19 |
f( |
| 20 |
+ void |
| 21 |
) { ... } |
| 22 |
|
| 23 |
// ---------------------------------------------------------------------------- |
| 24 |
|
| 25 |
@addvoid_context depends on !patch && (context || org || report)@ |
| 26 |
identifier f; |
| 27 |
position j0; |
| 28 |
@@ |
| 29 |
|
| 30 |
* f@j0( |
| 31 |
) { ... } |
| 32 |
|
| 33 |
// ---------------------------------------------------------------------------- |
| 34 |
|
| 35 |
@script:python addvoid_org depends on org@ |
| 36 |
f << addvoid_context.f; |
| 37 |
j0 << addvoid_context.j0; |
| 38 |
@@ |
| 39 |
|
| 40 |
msg = "WARNING: Zero-argument function \"%s\" should have void declaration " % (f) |
| 41 |
coccilib.org.print_safe_todo(j0[0], msg) |
| 42 |
|
| 43 |
// ---------------------------------------------------------------------------- |
| 44 |
|
| 45 |
@script:python addvoid_report depends on report@ |
| 46 |
f << addvoid_context.f; |
| 47 |
j0 << addvoid_context.j0; |
| 48 |
@@ |
| 49 |
|
| 50 |
msg = "WARNING: Zero-argument function \"%s\" should have void declaration " % (f) |
| 51 |
coccilib.report.print_report(j0[0], msg) |
| 52 |
|