summaryrefslogtreecommitdiff
path: root/coccinelle
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-11-16 14:42:14 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-16 16:05:29 +0100
commitf20db199541ea35c65edfeed9e5401cab6fe6bac (patch)
tree0c697e7e98ceb7e48a7776a401e2229a25aa6ee2 /coccinelle
parenta7891d203c5c8192ec16141c00a30d93e175a0cf (diff)
downloadsystemd-f20db199541ea35c65edfeed9e5401cab6fe6bac.tar.gz
cocci: simplify some if checks
Diffstat (limited to 'coccinelle')
-rw-r--r--coccinelle/redundant-if.cocci54
1 files changed, 54 insertions, 0 deletions
diff --git a/coccinelle/redundant-if.cocci b/coccinelle/redundant-if.cocci
new file mode 100644
index 0000000000..515e36e151
--- /dev/null
+++ b/coccinelle/redundant-if.cocci
@@ -0,0 +1,54 @@
+@@
+expression r;
+@@
+- if (r < 0)
+- return r;
+- if (r == 0)
+- return 0;
++ if (r <= 0)
++ return r;
+@@
+expression r;
+@@
+- if (r == 0)
+- return 0;
+- if (r < 0)
+- return r;
++ if (r <= 0)
++ return r;
+@@
+expression r;
+@@
+- if (r < 0)
+- return r;
+- if (r == 0)
+- return r;
++ if (r <= 0)
++ return r;
+@@
+expression r;
+@@
+- if (r == 0)
+- return r;
+- if (r < 0)
+- return r;
++ if (r <= 0)
++ return r;
+@@
+expression r;
+@@
+- if (r < 0)
+- return r;
+- if (r > 0)
+- return r;
++ if (r != 0)
++ return r;
+@@
+expression r;
+@@
+- if (r > 0)
+- return r;
+- if (r < 0)
+- return r;
++ if (r != 0)
++ return r;