From 3cc2aff1abff9e34f9fec282d970204dc1eab6f1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 8 Sep 2015 19:14:10 +0200 Subject: tree-wide: don't do assignments within if checks Turn this: if ((r = foo()) < 0) { ... into this: r = foo(); if (r < 0) { ... --- coccinelle/no-if-assignments.cocci | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 coccinelle/no-if-assignments.cocci (limited to 'coccinelle') diff --git a/coccinelle/no-if-assignments.cocci b/coccinelle/no-if-assignments.cocci new file mode 100644 index 0000000000..9f63e90337 --- /dev/null +++ b/coccinelle/no-if-assignments.cocci @@ -0,0 +1,20 @@ +@@ +expression p, q; +identifier r; +statement s; +@@ +- if ((r = q) < p) +- s ++ r = q; ++ if (r < p) ++ s +@@ +expression p, q; +identifier r; +statement s; +@@ +- if ((r = q) >= p) +- s ++ r = q; ++ if (r >= p) ++ s -- cgit v1.2.3-54-g00ecf