2019-06-04 11:11:38 +03:00
// SPDX-License-Identifier: GPL-2.0-only
2010-10-25 01:37:32 +04:00
/// Find &&/|| operations that include the same argument more than once
2018-08-03 19:32:11 +03:00
//# A common source of false positives is when the expression, or
//# another expresssion in the same && or || operation, performs a
//# side effect.
2010-10-25 01:37:32 +04:00
///
// Confidence: Moderate
2019-06-04 11:11:38 +03:00
// Copyright: (C) 2010 Nicolas Palix, DIKU.
// Copyright: (C) 2010 Julia Lawall, DIKU.
// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.
2022-08-07 19:19:54 +03:00
// URL: https://coccinelle.gitlabpages.inria.fr/website
2010-10-25 01:37:32 +04:00
// Comments:
2013-06-20 15:10:56 +04:00
// Options: --no-includes --include-headers
2010-10-25 01:37:32 +04:00
virtual context
virtual org
virtual report
@r expression@
expression E;
position p;
@@
(
2018-08-03 19:32:11 +03:00
E@p || ... || E
2010-10-25 01:37:32 +04:00
|
2018-08-03 19:32:11 +03:00
E@p && ... && E
2010-10-25 01:37:32 +04:00
)
2018-08-03 19:32:11 +03:00
@bad@
expression r.E,e1,e2,fn;
position r.p;
assignment operator op;
@@
(
E@p
&
<+... \(fn(...)\|e1 op e2\|e1++\|e1--\|++e1\|--e1\) ...+>
)
@depends on context && !bad@
expression r.E;
position r.p;
@@
*E@p
@script:python depends on org && !bad@
2010-10-25 01:37:32 +04:00
p << r.p;
@@
cocci.print_main("duplicated argument to && or ||",p)
2018-08-03 19:32:11 +03:00
@script:python depends on report && !bad@
2010-10-25 01:37:32 +04:00
p << r.p;
@@
coccilib.report.print_report(p[0],"duplicated argument to && or ||")