]> git.ipfire.org Git - thirdparty/systemd.git/blame - coccinelle/strempty.cocci
travis: use UBSan checks from OSS-Fuzz
[thirdparty/systemd.git] / coccinelle / strempty.cocci
CommitLineData
de896126 1@@
60d9959d
FS
2/* Avoid running this transformation on the strempty function itself */
3position p : script:python() { p[0].current_element != "strempty" };
de896126
DM
4expression s;
5@@
60d9959d
FS
6(
7- s@p ?: ""
de896126 8+ strempty(s)
60d9959d
FS
9|
10- s@p ? s : ""
de896126 11+ strempty(s)
60d9959d
FS
12)
13
ad5d4b17 14@@
60d9959d 15position p : script:python() { p[0].current_element != "strempty" };
ad5d4b17
LP
16expression s;
17@@
60d9959d 18- if (!s@p)
ad5d4b17
LP
19- s = "";
20+ s = strempty(s);
60d9959d 21
ad5d4b17 22@@
60d9959d 23position p : script:python() { p[0].current_element != "strnull" };
ad5d4b17
LP
24expression s;
25@@
60d9959d
FS
26(
27- s@p ?: "(null)"
ad5d4b17 28+ strnull(s)
60d9959d
FS
29|
30- s@p ? s : "(null)"
ad5d4b17 31+ strnull(s)
60d9959d
FS
32)
33
ad5d4b17 34@@
60d9959d 35position p : script:python() { p[0].current_element != "strnull" };
ad5d4b17
LP
36expression s;
37@@
60d9959d 38- if (!s@p)
ad5d4b17
LP
39- s = "(null)";
40+ s = strnull(s);
60d9959d 41
ad5d4b17 42@@
60d9959d 43position p : script:python() { p[0].current_element != "strna" };
ad5d4b17
LP
44expression s;
45@@
60d9959d
FS
46(
47- s@p ?: "n/a"
ad5d4b17 48+ strna(s)
60d9959d
FS
49|
50- s@p ? s : "n/a"
ad5d4b17 51+ strna(s)
60d9959d
FS
52)
53
ad5d4b17 54@@
60d9959d 55position p : script:python() { p[0].current_element != "strna" };
ad5d4b17
LP
56expression s;
57@@
60d9959d 58- if (!s@p)
ad5d4b17
LP
59- s = "n/a";
60+ s = strna(s);