summaryrefslogtreecommitdiffstats
path: root/coccinelle
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2023-03-18 13:56:38 +0100
committerFrantisek Sumsal <frantisek@sumsal.cz>2023-03-18 14:23:11 +0100
commit64254629f7e062a39156ee95428d46f2a1e82e06 (patch)
tree89df195daa93888c025d67b0b09228a0ec4cb6f2 /coccinelle
parentcoccinelle: respect spacing from the semantic patch (diff)
downloadsystemd-64254629f7e062a39156ee95428d46f2a1e82e06.tar.xz
systemd-64254629f7e062a39156ee95428d46f2a1e82e06.zip
coccinelle: add a transformation for GNU conditionals
i.e. x ? x : y => x ?: y
Diffstat (limited to 'coccinelle')
-rw-r--r--coccinelle/cond-omit-middle.cocci7
1 files changed, 7 insertions, 0 deletions
diff --git a/coccinelle/cond-omit-middle.cocci b/coccinelle/cond-omit-middle.cocci
new file mode 100644
index 0000000000..f1587b8db3
--- /dev/null
+++ b/coccinelle/cond-omit-middle.cocci
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/* See: https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html#Conditionals */
+@@
+expression e, x;
+@@
+- e ? e : x
++ e ?: x