aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2018-08-03 12:32:11 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-08-13 19:58:49 -0400
commit09d4d9648bd01a4c124fcc30dd0c31503975e8c2 (patch)
tree8060cb4a4b28c630f6afc8fc5a9be1307e14b58a
parentd6c6ab93e17f139c9b7f9b077307ebddc05a7990 (diff)
Coccinelle: doubletest: reduce side effect false positives
Ensure that the cited expression is not a function call or an assignment to reduce the chance of false positives. Slightly modify the warning message to indicate another source of false positves. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r--scripts/coccinelle/tests/doubletest.cocci34
1 files changed, 26 insertions, 8 deletions
diff --git a/scripts/coccinelle/tests/doubletest.cocci b/scripts/coccinelle/tests/doubletest.cocci
index 78d74c22ca12..7af2ce7eb9bf 100644
--- a/scripts/coccinelle/tests/doubletest.cocci
+++ b/scripts/coccinelle/tests/doubletest.cocci
@@ -1,6 +1,7 @@
1/// Find &&/|| operations that include the same argument more than once 1/// Find &&/|| operations that include the same argument more than once
2//# A common source of false positives is when the argument performs a side 2//# A common source of false positives is when the expression, or
3//# effect. 3//# another expresssion in the same && or || operation, performs a
4//# side effect.
4/// 5///
5// Confidence: Moderate 6// Confidence: Moderate
6// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. 7// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
@@ -20,20 +21,37 @@ position p;
20@@ 21@@
21 22
22( 23(
23* E@p 24 E@p || ... || E
24 || ... || E
25| 25|
26* E@p 26 E@p && ... && E
27 && ... && E
28) 27)
29 28
30@script:python depends on org@ 29@bad@
30expression r.E,e1,e2,fn;
31position r.p;
32assignment operator op;
33@@
34
35(
36E@p
37&
38 <+... \(fn(...)\|e1 op e2\|e1++\|e1--\|++e1\|--e1\) ...+>
39)
40
41@depends on context && !bad@
42expression r.E;
43position r.p;
44@@
45
46*E@p
47
48@script:python depends on org && !bad@
31p << r.p; 49p << r.p;
32@@ 50@@
33 51
34cocci.print_main("duplicated argument to && or ||",p) 52cocci.print_main("duplicated argument to && or ||",p)
35 53
36@script:python depends on report@ 54@script:python depends on report && !bad@
37p << r.p; 55p << r.p;
38@@ 56@@
39 57