orplus.cocci 900 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /// Check for constants that are added but are used elsewhere as bitmasks
  2. /// The results should be checked manually to ensure that the nonzero
  3. /// bits in the two constants are actually disjoint.
  4. ///
  5. // Confidence: Moderate
  6. // Copyright: (C) 2013 Julia Lawall, INRIA/LIP6. GPLv2.
  7. // Copyright: (C) 2013 Gilles Muller, INRIA/LIP6. GPLv2.
  8. // URL: http://coccinelle.lip6.fr/
  9. // Comments:
  10. // Options: --no-includes --include-headers
  11. virtual org
  12. virtual report
  13. virtual context
  14. @r@
  15. constant c;
  16. identifier i;
  17. expression e;
  18. @@
  19. (
  20. e | c@i
  21. |
  22. e & c@i
  23. |
  24. e |= c@i
  25. |
  26. e &= c@i
  27. )
  28. @s@
  29. constant r.c,c1;
  30. identifier i1;
  31. position p;
  32. @@
  33. (
  34. c1 + c - 1
  35. |
  36. *c1@i1 +@p c
  37. )
  38. @script:python depends on org@
  39. p << s.p;
  40. @@
  41. cocci.print_main("sum of probable bitmasks, consider |",p)
  42. @script:python depends on report@
  43. p << s.p;
  44. @@
  45. msg = "WARNING: sum of probable bitmasks, consider |"
  46. coccilib.report.print_report(p[0],msg)