1:255.16-alt1
[systemd_ALT.git] / coccinelle / take-fd.cocci
blob15f1e7c2ce339bf1403c46440c07e45527f3cedd
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 @@
3 local idexpression p;
4 expression q;
5 @@
6 - p = q;
7 - q = -EBADF;
8 - return p;
9 + return TAKE_FD(q);
11 /* The ideal solution would use 'local idexpression' to avoid matching errno,
12  * which is a global variable. However, 'idexpression' nor 'identifier'
13  * would match, for example, "x->fd", which is considered 'expression' in
14  * the SmPL grammar
15  */
17 expression p != errno;
18 expression q;
20 - p = q;
21 - q = -EBADF;
22 + p = TAKE_FD(q);