doubletest.cocci (e5451c8f8330e03ad3cfa16048b4daf961af434f) doubletest.cocci (09d4d9648bd01a4c124fcc30dd0c31503975e8c2)
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
3//# effect.
2//# A common source of false positives is when the expression, or
3//# another expresssion in the same && or || operation, performs a
4//# side effect.
4///
5// Confidence: Moderate
6// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
7// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
8// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
9// URL: http://coccinelle.lip6.fr/
10// Comments:
11// Options: --no-includes --include-headers
12
13virtual context
14virtual org
15virtual report
16
17@r expression@
18expression E;
19position p;
20@@
21
22(
5///
6// Confidence: Moderate
7// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
8// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
9// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
10// URL: http://coccinelle.lip6.fr/
11// Comments:
12// Options: --no-includes --include-headers
13
14virtual context
15virtual org
16virtual report
17
18@r expression@
19expression E;
20position p;
21@@
22
23(
23* E@p
24 || ... || E
24 E@p || ... || E
25|
25|
26* E@p
27 && ... && E
26 E@p && ... && E
28)
29
27)
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;
32@@
33
34cocci.print_main("duplicated argument to && or ||",p)
35
49p << r.p;
50@@
51
52cocci.print_main("duplicated argument to && or ||",p)
53
36@script:python depends on report@
54@script:python depends on report && !bad@
37p << r.p;
38@@
39
40coccilib.report.print_report(p[0],"duplicated argument to && or ||")
55p << r.p;
56@@
57
58coccilib.report.print_report(p[0],"duplicated argument to && or ||")