]> git.ipfire.org Git - thirdparty/systemd.git/blob - coccinelle/take-fd.cocci
nspawn: rework how /run/host/ is set up
[thirdparty/systemd.git] / coccinelle / take-fd.cocci
1 @@
2 local idexpression p;
3 expression q;
4 @@
5 - p = q;
6 - q = -1;
7 - return p;
8 + return TAKE_FD(q);
9
10 /* The ideal solution would use 'local idexpression' to avoid matching errno,
11 * which is a global variable. However, 'idexpression' nor 'identifier'
12 * would match, for example, "x->fd", which is considered 'expression' in
13 * the SmPL grammar
14 */
15 @@
16 expression p != errno;
17 expression q;
18 @@
19 - p = q;
20 - q = -1;
21 + p = TAKE_FD(q);