^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /// Find bit operations that include the same argument more than once
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) //# One source of false positives is when the argument performs a side
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) //# effect. Another source of false positives is when a neutral value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) //# such as 0 for | is used to indicate no information, to maintain the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) //# same structure as other similar expressions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ///
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) // Confidence: Moderate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) // Copyright: (C) 2010 Nicolas Palix, DIKU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) // Copyright: (C) 2010 Julia Lawall, DIKU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) // URL: http://coccinelle.lip6.fr/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) // Comments:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) // Options: --no-includes --include-headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) virtual context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) virtual org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) virtual report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) @r expression@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) expression E;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) position p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * E@p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) & ... & E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * E@p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) | ... | E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * E@p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) & ... & !E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * E@p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) | ... | !E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * !E@p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) & ... & E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * !E@p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) | ... | E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) p << r.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) cocci.print_main("duplicated argument to & or |",p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) p << r.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) coccilib.report.print_report(p[0],"duplicated argument to & or |")