1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00
systemd/coccinelle/take-fd.cocci
Lennart Poettering c10d6bdb89 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.
2018-03-22 20:30:40 +01:00

15 lines
154 B
Plaintext

@@
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);