summaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle/return_directly.cocci
blob: 48680f2c2a73b073caa9180c163c73b6bea34d2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// replace 'R = X; return R;' with 'return R;'
@@
identifier VAR;
expression E;
type T;
identifier F;
@@
 T F(...)
 {
     ...
-    T VAR;
     ... when != VAR

-    VAR =
+    return
     E;
-    return VAR;
     ... when != VAR
 }