]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coccinelle: introduce drop-braces transformation
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 9 Oct 2020 10:45:03 +0000 (12:45 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 9 Oct 2020 13:02:20 +0000 (15:02 +0200)
to drop braces around single-line if statements. Also, prefix it with
zz- so it runs as the last one, so it's able to fix stuff tweaked by
previous transformations.

coccinelle/zz-drop-braces.cocci [new file with mode: 0644]

diff --git a/coccinelle/zz-drop-braces.cocci b/coccinelle/zz-drop-braces.cocci
new file mode 100644 (file)
index 0000000..34bf12f
--- /dev/null
@@ -0,0 +1,27 @@
+@@
+position p : script:python() { p[0].file != "src/journal/lookup3.c" };
+identifier id;
+expression e;
+@@
+if (...)
+- {
+(
+    id@p(...);
+|
+    e@p;
+)
+- }
+
+@@
+position p : script:python() { p[0].file != "src/journal/lookup3.c" };
+identifier id;
+expression e;
+@@
+if (...)
+- {
+(
+    return id@p(...);
+|
+    return e@p;
+)
+- }