197c1cf8fSJulia Lawall/// Find &&/|| operations that include the same argument more than once 2*09d4d964SJulia Lawall//# A common source of false positives is when the expression, or 3*09d4d964SJulia Lawall//# another expresssion in the same && or || operation, performs a 4*09d4d964SJulia Lawall//# side effect. 597c1cf8fSJulia Lawall/// 697c1cf8fSJulia Lawall// Confidence: Moderate 797c1cf8fSJulia Lawall// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. 897c1cf8fSJulia Lawall// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. 997c1cf8fSJulia Lawall// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. 1097c1cf8fSJulia Lawall// URL: http://coccinelle.lip6.fr/ 1197c1cf8fSJulia Lawall// Comments: 1293f14468SNicolas Palix// Options: --no-includes --include-headers 1397c1cf8fSJulia Lawall 1497c1cf8fSJulia Lawallvirtual context 1597c1cf8fSJulia Lawallvirtual org 1697c1cf8fSJulia Lawallvirtual report 1797c1cf8fSJulia Lawall 1897c1cf8fSJulia Lawall@r expression@ 1997c1cf8fSJulia Lawallexpression E; 2097c1cf8fSJulia Lawallposition p; 2197c1cf8fSJulia Lawall@@ 2297c1cf8fSJulia Lawall 2397c1cf8fSJulia Lawall( 24*09d4d964SJulia Lawall E@p || ... || E 2597c1cf8fSJulia Lawall| 26*09d4d964SJulia Lawall E@p && ... && E 2797c1cf8fSJulia Lawall) 2897c1cf8fSJulia Lawall 29*09d4d964SJulia Lawall@bad@ 30*09d4d964SJulia Lawallexpression r.E,e1,e2,fn; 31*09d4d964SJulia Lawallposition r.p; 32*09d4d964SJulia Lawallassignment operator op; 33*09d4d964SJulia Lawall@@ 34*09d4d964SJulia Lawall 35*09d4d964SJulia Lawall( 36*09d4d964SJulia LawallE@p 37*09d4d964SJulia Lawall& 38*09d4d964SJulia Lawall <+... \(fn(...)\|e1 op e2\|e1++\|e1--\|++e1\|--e1\) ...+> 39*09d4d964SJulia Lawall) 40*09d4d964SJulia Lawall 41*09d4d964SJulia Lawall@depends on context && !bad@ 42*09d4d964SJulia Lawallexpression r.E; 43*09d4d964SJulia Lawallposition r.p; 44*09d4d964SJulia Lawall@@ 45*09d4d964SJulia Lawall 46*09d4d964SJulia Lawall*E@p 47*09d4d964SJulia Lawall 48*09d4d964SJulia Lawall@script:python depends on org && !bad@ 4997c1cf8fSJulia Lawallp << r.p; 5097c1cf8fSJulia Lawall@@ 5197c1cf8fSJulia Lawall 5297c1cf8fSJulia Lawallcocci.print_main("duplicated argument to && or ||",p) 5397c1cf8fSJulia Lawall 54*09d4d964SJulia Lawall@script:python depends on report && !bad@ 5597c1cf8fSJulia Lawallp << r.p; 5697c1cf8fSJulia Lawall@@ 5797c1cf8fSJulia Lawall 5897c1cf8fSJulia Lawallcoccilib.report.print_report(p[0],"duplicated argument to && or ||") 59