diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/coccinelle/return_directly.cocci | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/coccinelle/return_directly.cocci b/scripts/coccinelle/return_directly.cocci new file mode 100644 index 0000000000..48680f2c2a --- /dev/null +++ b/scripts/coccinelle/return_directly.cocci @@ -0,0 +1,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 + } |