doubletest.cocci 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /// Find &&/|| operations that include the same argument more than once
  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.
  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. virtual context
  14. virtual org
  15. virtual report
  16. @r expression@
  17. expression E;
  18. position p;
  19. @@
  20. (
  21. E@p || ... || E
  22. |
  23. E@p && ... && E
  24. )
  25. @bad@
  26. expression r.E,e1,e2,fn;
  27. position r.p;
  28. assignment operator op;
  29. @@
  30. (
  31. E@p
  32. &
  33. <+... \(fn(...)\|e1 op e2\|e1++\|e1--\|++e1\|--e1\) ...+>
  34. )
  35. @depends on context && !bad@
  36. expression r.E;
  37. position r.p;
  38. @@
  39. *E@p
  40. @script:python depends on org && !bad@
  41. p << r.p;
  42. @@
  43. cocci.print_main("duplicated argument to && or ||",p)
  44. @script:python depends on report && !bad@
  45. p << r.p;
  46. @@
  47. coccilib.report.print_report(p[0],"duplicated argument to && or ||")