summaryrefslogtreecommitdiff
path: root/coccinelle
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-03-22 17:04:29 +0100
committerLennart Poettering <lennart@poettering.net>2018-03-22 20:30:40 +0100
commitc10d6bdb891881f68471dabd8100ea6021e6cdbb (patch)
tree99f77908217b88a1b49c1ef23d1e27c493ba30e4 /coccinelle
parent2f4cefe6ce00a38988830e88f7b16acfb6b21b3c (diff)
macro: introduce new TAKE_FD() macro
This is similar to TAKE_PTR() but operates on file descriptors, and thus assigns -1 to the fd parameter after returning it. Removes 60 lines from our codebase. Pretty good too I think.
Diffstat (limited to 'coccinelle')
-rw-r--r--coccinelle/take-fd.cocci14
1 files changed, 14 insertions, 0 deletions
diff --git a/coccinelle/take-fd.cocci b/coccinelle/take-fd.cocci
new file mode 100644
index 0000000000..ba242483cd
--- /dev/null
+++ b/coccinelle/take-fd.cocci
@@ -0,0 +1,14 @@
+@@
+local idexpression p;
+expression q;
+@@
+- p = q;
+- q = -1;
+- return p;
++ return TAKE_FD(q);
+@@
+expression p, q;
+@@
+- p = q;
+- q = -1;
++ p = TAKE_FD(q);