]> git.ipfire.org Git - thirdparty/systemd.git/blob - coccinelle/strempty.cocci
fs-util: no need for fchmod_and_chown() to access /proc/self/fd directly
[thirdparty/systemd.git] / coccinelle / strempty.cocci
1 @@
2 /* Avoid running this transformation on the strempty function itself */
3 position p : script:python() { p[0].current_element != "strempty" };
4 expression s;
5 @@
6 (
7 - s@p ?: ""
8 + strempty(s)
9 |
10 - s@p ? s : ""
11 + strempty(s)
12 )
13
14 @@
15 position p : script:python() { p[0].current_element != "strempty" };
16 expression s;
17 @@
18 - if (!s@p)
19 - s = "";
20 + s = strempty(s);
21
22 @@
23 position p : script:python() { p[0].current_element != "strnull" };
24 expression s;
25 @@
26 (
27 - s@p ?: "(null)"
28 + strnull(s)
29 |
30 - s@p ? s : "(null)"
31 + strnull(s)
32 )
33
34 @@
35 position p : script:python() { p[0].current_element != "strnull" };
36 expression s;
37 @@
38 - if (!s@p)
39 - s = "(null)";
40 + s = strnull(s);
41
42 @@
43 position p : script:python() { p[0].current_element != "strna" };
44 expression s;
45 @@
46 (
47 - s@p ?: "n/a"
48 + strna(s)
49 |
50 - s@p ? s : "n/a"
51 + strna(s)
52 )
53
54 @@
55 position p : script:python() { p[0].current_element != "strna" };
56 expression s;
57 @@
58 - if (!s@p)
59 - s = "n/a";
60 + s = strna(s);