summaryrefslogtreecommitdiffstats
path: root/coccinelle/empty-to-root.cocci
diff options
context:
space:
mode:
Diffstat (limited to 'coccinelle/empty-to-root.cocci')
-rw-r--r--coccinelle/empty-to-root.cocci17
1 files changed, 17 insertions, 0 deletions
diff --git a/coccinelle/empty-to-root.cocci b/coccinelle/empty-to-root.cocci
new file mode 100644
index 0000000..9a65a69
--- /dev/null
+++ b/coccinelle/empty-to-root.cocci
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+@@
+expression s;
+@@
+- if (empty_or_root(s))
+- s = "/";
++ s = empty_to_root(s);
+@@
+expression s;
+@@
+- (empty_or_root(s) ? "/" : s)
++ empty_to_root(s)
+@@
+expression s;
+@@
+- (s ? s : "/")
++ empty_to_root(s)