2015-09-30 13:23:57 +03:00
@@
2020-04-21 21:23:33 +03:00
/* Avoid running this transformation on the strempty function itself and
* on the "make_expression" macro in src/libsystemd/sd-bus/bus-convenience.c.
* As Coccinelle's Location object doesn't support macro "detection", use
* a pretty horrifying combo of specifying a file and a special "something_else"
* position element, which is, apparently, the default value of
* "current_element" before it's set (according to the source code), thus
* matching any "top level" position, including macros. Let's hope we never
* introduce a function called "something_else"...
*/
position p : script:python() {
not (p[0].current_element == "strempty" or
(p[0].file == "src/libsystemd/sd-bus/bus-convenience.c" and
p[0].current_element == "something_else"))
};
2015-09-30 13:23:57 +03:00
expression s;
@@
2019-04-28 18:13:29 +03:00
(
- s@p ?: ""
2015-09-30 13:23:57 +03:00
+ strempty(s)
2019-04-28 18:13:29 +03:00
|
- s@p ? s : ""
2015-09-30 13:23:57 +03:00
+ strempty(s)
2019-04-28 18:13:29 +03:00
)
2018-01-10 19:11:19 +03:00
@@
2019-04-28 18:13:29 +03:00
position p : script:python() { p[0].current_element != "strempty" };
2018-01-10 19:11:19 +03:00
expression s;
@@
2019-04-28 18:13:29 +03:00
- if (!s@p)
2018-01-10 19:11:19 +03:00
- s = "";
+ s = strempty(s);
2019-04-28 18:13:29 +03:00
2018-01-10 19:11:19 +03:00
@@
2019-04-28 18:13:29 +03:00
position p : script:python() { p[0].current_element != "strnull" };
2018-01-10 19:11:19 +03:00
expression s;
@@
2019-04-28 18:13:29 +03:00
(
- s@p ?: "(null)"
2018-01-10 19:11:19 +03:00
+ strnull(s)
2019-04-28 18:13:29 +03:00
|
- s@p ? s : "(null)"
2018-01-10 19:11:19 +03:00
+ strnull(s)
2019-04-28 18:13:29 +03:00
)
2018-01-10 19:11:19 +03:00
@@
2019-04-28 18:13:29 +03:00
position p : script:python() { p[0].current_element != "strnull" };
2018-01-10 19:11:19 +03:00
expression s;
@@
2019-04-28 18:13:29 +03:00
- if (!s@p)
2018-01-10 19:11:19 +03:00
- s = "(null)";
+ s = strnull(s);
2019-04-28 18:13:29 +03:00
2018-01-10 19:11:19 +03:00
@@
2019-04-28 18:13:29 +03:00
position p : script:python() { p[0].current_element != "strna" };
2018-01-10 19:11:19 +03:00
expression s;
@@
2019-04-28 18:13:29 +03:00
(
- s@p ?: "n/a"
2018-01-10 19:11:19 +03:00
+ strna(s)
2019-04-28 18:13:29 +03:00
|
- s@p ? s : "n/a"
2018-01-10 19:11:19 +03:00
+ strna(s)
2019-04-28 18:13:29 +03:00
)
2018-01-10 19:11:19 +03:00
@@
2019-04-28 18:13:29 +03:00
position p : script:python() { p[0].current_element != "strna" };
2018-01-10 19:11:19 +03:00
expression s;
@@
2019-04-28 18:13:29 +03:00
- if (!s@p)
2018-01-10 19:11:19 +03:00
- s = "n/a";
+ s = strna(s);