string_choices.cocci 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /// Find places to use string_choices.h's various helpers.
  3. //
  4. // Confidence: Medium
  5. // Options: --no-includes --include-headers
  6. virtual patch
  7. virtual context
  8. virtual report
  9. @str_plural depends on patch@
  10. expression E;
  11. @@
  12. (
  13. - ((E == 1) ? "" : "s")
  14. + str_plural(E)
  15. |
  16. - ((E > 1) ? "s" : "")
  17. + str_plural(E)
  18. )
  19. @str_plural_r depends on !patch@
  20. expression E;
  21. position P;
  22. @@
  23. (
  24. * (E@P == 1) ? "" : "s"
  25. |
  26. * (E@P > 1) ? "s" : ""
  27. )
  28. @script:python depends on report@
  29. p << str_plural_r.P;
  30. e << str_plural_r.E;
  31. @@
  32. coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)
  33. @str_up_down depends on patch disable neg_if_exp@
  34. expression E;
  35. @@
  36. - ((E) ? "up" : "down")
  37. + str_up_down(E)
  38. @str_up_down_r depends on !patch disable neg_if_exp@
  39. expression E;
  40. position P;
  41. @@
  42. * E@P ? "up" : "down"
  43. @script:python depends on report@
  44. p << str_up_down_r.P;
  45. e << str_up_down_r.E;
  46. @@
  47. coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
  48. @str_down_up depends on patch disable neg_if_exp@
  49. expression E;
  50. @@
  51. - ((E) ? "down" : "up")
  52. + str_down_up(E)
  53. @str_down_up_r depends on !patch disable neg_if_exp@
  54. expression E;
  55. position P;
  56. @@
  57. * E@P ? "down" : "up"
  58. @script:python depends on report@
  59. p << str_down_up_r.P;
  60. e << str_down_up_r.E;
  61. @@
  62. coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e)
  63. @str_true_false depends on patch disable neg_if_exp@
  64. expression E;
  65. @@
  66. - ((E) ? "true" : "false")
  67. + str_true_false(E)
  68. @str_true_false_r depends on !patch disable neg_if_exp@
  69. expression E;
  70. position P;
  71. @@
  72. * E@P ? "true" : "false"
  73. @script:python depends on report@
  74. p << str_true_false_r.P;
  75. e << str_true_false_r.E;
  76. @@
  77. coccilib.report.print_report(p[0], "opportunity for str_true_false(%s)" % e)
  78. @str_false_true depends on patch disable neg_if_exp@
  79. expression E;
  80. @@
  81. - ((E) ? "false" : "true")
  82. + str_false_true(E)
  83. @str_false_true_r depends on !patch disable neg_if_exp@
  84. expression E;
  85. position P;
  86. @@
  87. * E@P ? "false" : "true"
  88. @script:python depends on report@
  89. p << str_false_true_r.P;
  90. e << str_false_true_r.E;
  91. @@
  92. coccilib.report.print_report(p[0], "opportunity for str_false_true(%s)" % e)
  93. @str_hi_lo depends on patch disable neg_if_exp@
  94. expression E;
  95. @@
  96. - ((E) ? "hi" : "lo")
  97. + str_hi_lo(E)
  98. @str_hi_lo_r depends on !patch disable neg_if_exp@
  99. expression E;
  100. position P;
  101. @@
  102. * E@P ? "hi" : "lo"
  103. @script:python depends on report@
  104. p << str_hi_lo_r.P;
  105. e << str_hi_lo_r.E;
  106. @@
  107. coccilib.report.print_report(p[0], "opportunity for str_hi_lo(%s)" % e)
  108. @str_high_low depends on patch disable neg_if_exp@
  109. expression E;
  110. @@
  111. - ((E) ? "high" : "low")
  112. + str_high_low(E)
  113. @str_high_low_r depends on !patch disable neg_if_exp@
  114. expression E;
  115. position P;
  116. @@
  117. * E@P ? "high" : "low"
  118. @script:python depends on report@
  119. p << str_high_low_r.P;
  120. e << str_high_low_r.E;
  121. @@
  122. coccilib.report.print_report(p[0], "opportunity for str_high_low(%s)" % e)
  123. @str_lo_hi depends on patch disable neg_if_exp@
  124. expression E;
  125. @@
  126. - ((E) ? "lo" : "hi")
  127. + str_lo_hi(E)
  128. @str_lo_hi_r depends on !patch disable neg_if_exp@
  129. expression E;
  130. position P;
  131. @@
  132. * E@P ? "lo" : "hi"
  133. @script:python depends on report@
  134. p << str_lo_hi_r.P;
  135. e << str_lo_hi_r.E;
  136. @@
  137. coccilib.report.print_report(p[0], "opportunity for str_lo_hi(%s)" % e)
  138. @str_low_high depends on patch disable neg_if_exp@
  139. expression E;
  140. @@
  141. - ((E) ? "low" : "high")
  142. + str_low_high(E)
  143. @str_low_high_r depends on !patch disable neg_if_exp@
  144. expression E;
  145. position P;
  146. @@
  147. * E@P ? "low" : "high"
  148. @script:python depends on report@
  149. p << str_low_high_r.P;
  150. e << str_low_high_r.E;
  151. @@
  152. coccilib.report.print_report(p[0], "opportunity for str_low_high(%s)" % e)
  153. @str_enable_disable depends on patch@
  154. expression E;
  155. @@
  156. - ((E) ? "enable" : "disable")
  157. + str_enable_disable(E)
  158. @str_enable_disable_r depends on !patch@
  159. expression E;
  160. position P;
  161. @@
  162. * E@P ? "enable" : "disable"
  163. @script:python depends on report@
  164. p << str_enable_disable_r.P;
  165. e << str_enable_disable_r.E;
  166. @@
  167. coccilib.report.print_report(p[0], "opportunity for str_enable_disable(%s)" % e)
  168. @str_enabled_disabled depends on patch@
  169. expression E;
  170. @@
  171. - ((E) ? "enabled" : "disabled")
  172. + str_enabled_disabled(E)
  173. @str_enabled_disabled_r depends on !patch@
  174. expression E;
  175. position P;
  176. @@
  177. * E@P ? "enabled" : "disabled"
  178. @script:python depends on report@
  179. p << str_enabled_disabled_r.P;
  180. e << str_enabled_disabled_r.E;
  181. @@
  182. coccilib.report.print_report(p[0], "opportunity for str_enabled_disabled(%s)" % e)
  183. @str_read_write depends on patch disable neg_if_exp@
  184. expression E;
  185. @@
  186. - ((E) ? "read" : "write")
  187. + str_read_write(E)
  188. @str_read_write_r depends on !patch disable neg_if_exp@
  189. expression E;
  190. position P;
  191. @@
  192. * E@P ? "read" : "write"
  193. @script:python depends on report@
  194. p << str_read_write_r.P;
  195. e << str_read_write_r.E;
  196. @@
  197. coccilib.report.print_report(p[0], "opportunity for str_read_write(%s)" % e)
  198. @str_write_read depends on patch disable neg_if_exp@
  199. expression E;
  200. @@
  201. - ((E) ? "write" : "read")
  202. + str_write_read(E)
  203. @str_write_read_r depends on !patch disable neg_if_exp@
  204. expression E;
  205. position P;
  206. @@
  207. * E@P ? "write" : "read"
  208. @script:python depends on report@
  209. p << str_write_read_r.P;
  210. e << str_write_read_r.E;
  211. @@
  212. coccilib.report.print_report(p[0], "opportunity for str_write_read(%s)" % e)
  213. @str_on_off depends on patch@
  214. expression E;
  215. @@
  216. - ((E) ? "on" : "off")
  217. + str_on_off(E)
  218. @str_on_off_r depends on !patch@
  219. expression E;
  220. position P;
  221. @@
  222. * E@P ? "on" : "off"
  223. @script:python depends on report@
  224. p << str_on_off_r.P;
  225. e << str_on_off_r.E;
  226. @@
  227. coccilib.report.print_report(p[0], "opportunity for str_on_off(%s)" % e)
  228. @str_yes_no depends on patch@
  229. expression E;
  230. @@
  231. - ((E) ? "yes" : "no")
  232. + str_yes_no(E)
  233. @str_yes_no_r depends on !patch@
  234. expression E;
  235. position P;
  236. @@
  237. * E@P ? "yes" : "no"
  238. @script:python depends on report@
  239. p << str_yes_no_r.P;
  240. e << str_yes_no_r.E;
  241. @@
  242. coccilib.report.print_report(p[0], "opportunity for str_yes_no(%s)" % e)