orplus.cocci 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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,c1;
  16. identifier i,i1;
  17. position p;
  18. @@
  19. (
  20. c1 + c - 1
  21. |
  22. c1@i1 +@p c@i
  23. )
  24. @s@
  25. constant r.c, r.c1;
  26. identifier i;
  27. expression e;
  28. @@
  29. (
  30. e | c@i
  31. |
  32. e & c@i
  33. |
  34. e |= c@i
  35. |
  36. e &= c@i
  37. |
  38. e | c1@i
  39. |
  40. e & c1@i
  41. |
  42. e |= c1@i
  43. |
  44. e &= c1@i
  45. )
  46. @depends on s@
  47. position r.p;
  48. constant c1,c2;
  49. @@
  50. * c1 +@p c2
  51. @script:python depends on s && org@
  52. p << r.p;
  53. @@
  54. cocci.print_main("sum of probable bitmasks, consider |",p)
  55. @script:python depends on s && report@
  56. p << r.p;
  57. @@
  58. msg = "WARNING: sum of probable bitmasks, consider |"
  59. coccilib.report.print_report(p[0],msg)