Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /// Find bit operations that include the same argument more than once
0003 //# One source of false positives is when the argument performs a side
0004 //# effect.  Another source of false positives is when a neutral value
0005 //# such as 0 for | is used to indicate no information, to maintain the
0006 //# same structure as other similar expressions
0007 ///
0008 // Confidence: Moderate
0009 // Copyright: (C) 2010 Nicolas Palix, DIKU.
0010 // Copyright: (C) 2010 Julia Lawall, DIKU.
0011 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.
0012 // URL: https://coccinelle.gitlabpages.inria.fr/website
0013 // Comments:
0014 // Options: --no-includes --include-headers
0015 
0016 virtual context
0017 virtual org
0018 virtual report
0019 
0020 @r expression@
0021 expression E;
0022 position p;
0023 @@
0024 
0025 (
0026 *        E@p
0027          & ... & E
0028 |
0029 *        E@p
0030          | ... | E
0031 |
0032 *        E@p
0033          & ... & !E
0034 |
0035 *        E@p
0036          | ... | !E
0037 |
0038 *        !E@p
0039          & ... & E
0040 |
0041 *        !E@p
0042          | ... | E
0043 )
0044 
0045 @script:python depends on org@
0046 p << r.p;
0047 @@
0048 
0049 cocci.print_main("duplicated argument to & or |",p)
0050 
0051 @script:python depends on report@
0052 p << r.p;
0053 @@
0054 
0055 coccilib.report.print_report(p[0],"duplicated argument to & or |")