~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/scripts/coccinelle/api/alloc/zalloc-simple.cocci

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /scripts/coccinelle/api/alloc/zalloc-simple.cocci (Version linux-6.12-rc7) and /scripts/coccinelle/api/alloc/zalloc-simple.cocci (Version linux-4.20.17)


  1 // SPDX-License-Identifier: GPL-2.0-only       << 
  2 ///                                                 1 ///
  3 /// Use zeroing allocator rather than allocato      2 /// Use zeroing allocator rather than allocator followed by memset with 0
  4 ///                                                 3 ///
  5 /// This considers some simple cases that are       4 /// This considers some simple cases that are common and easy to validate
  6 /// Note in particular that there are no ...s       5 /// Note in particular that there are no ...s in the rule, so all of the
  7 /// matched code has to be contiguous               6 /// matched code has to be contiguous
  8 ///                                                 7 ///
  9 // Confidence: High                                 8 // Confidence: High
 10 // Copyright: (C) 2009-2010 Julia Lawall, Nico !!   9 // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU.  GPLv2.
 11 // Copyright: (C) 2009-2010 Gilles Muller, INR !!  10 // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 12 // Copyright: (C) 2017 Himanshu Jha            !!  11 // Copyright: (C) 2017 Himanshu Jha GPLv2.
 13 // URL: https://coccinelle.gitlabpages.inria.f !!  12 // URL: http://coccinelle.lip6.fr/rules/kzalloc.html
 14 // Options: --no-includes --include-headers        13 // Options: --no-includes --include-headers
 15 //                                                 14 //
 16 // Keywords: kmalloc, kzalloc                      15 // Keywords: kmalloc, kzalloc
 17 // Version min: < 2.6.12 kmalloc                   16 // Version min: < 2.6.12 kmalloc
 18 // Version min:   2.6.14 kzalloc                   17 // Version min:   2.6.14 kzalloc
 19 //                                                 18 //
 20                                                    19 
 21 virtual context                                    20 virtual context
 22 virtual patch                                      21 virtual patch
 23 virtual org                                        22 virtual org
 24 virtual report                                     23 virtual report
 25                                                    24 
 26 //--------------------------------------------     25 //----------------------------------------------------------
 27 //  For context mode                               26 //  For context mode
 28 //--------------------------------------------     27 //----------------------------------------------------------
 29                                                    28 
 30 @depends on context@                               29 @depends on context@
 31 type T, T2;                                        30 type T, T2;
 32 expression x;                                      31 expression x;
 33 expression E1;                                     32 expression E1;
 34 statement S;                                       33 statement S;
 35 @@                                                 34 @@
 36                                                    35 
 37 * x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_     36 * x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
 38   kmalloc_node(E1, ...)\|kmem_cache_alloc(...)     37   kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
 39   devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\     38   devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|kvmalloc_node(E1,...)\);
 40   if ((x==NULL) || ...) S                          39   if ((x==NULL) || ...) S
 41 * memset((T2)x,0,E1);                              40 * memset((T2)x,0,E1);
 42                                                    41 
 43 //--------------------------------------------     42 //----------------------------------------------------------
 44 //  For patch mode                                 43 //  For patch mode
 45 //--------------------------------------------     44 //----------------------------------------------------------
 46                                                    45 
 47 @depends on patch@                                 46 @depends on patch@
 48 type T, T2;                                        47 type T, T2;
 49 expression x;                                      48 expression x;
 50 expression E1,E2,E3,E4;                            49 expression E1,E2,E3,E4;
 51 statement S;                                       50 statement S;
 52 @@                                                 51 @@
 53                                                    52 
 54 (                                                  53 (
 55 - x = kmalloc(E1,E2);                              54 - x = kmalloc(E1,E2);
 56 + x = kzalloc(E1,E2);                              55 + x = kzalloc(E1,E2);
 57 |                                                  56 |
 58 - x = (T *)kmalloc(E1,E2);                         57 - x = (T *)kmalloc(E1,E2);
 59 + x = kzalloc(E1,E2);                              58 + x = kzalloc(E1,E2);
 60 |                                                  59 |
 61 - x = (T)kmalloc(E1,E2);                           60 - x = (T)kmalloc(E1,E2);
 62 + x = (T)kzalloc(E1,E2);                           61 + x = (T)kzalloc(E1,E2);
 63 |                                                  62 |
 64 - x = vmalloc(E1);                                 63 - x = vmalloc(E1);
 65 + x = vzalloc(E1);                                 64 + x = vzalloc(E1);
 66 |                                                  65 |
 67 - x = (T *)vmalloc(E1);                            66 - x = (T *)vmalloc(E1);
 68 + x = vzalloc(E1);                                 67 + x = vzalloc(E1);
 69 |                                                  68 |
 70 - x = (T)vmalloc(E1);                              69 - x = (T)vmalloc(E1);
 71 + x = (T)vzalloc(E1);                              70 + x = (T)vzalloc(E1);
 72 |                                                  71 |
                                                   >>  72 - x = dma_alloc_coherent(E2,E1,E3,E4);
                                                   >>  73 + x = dma_zalloc_coherent(E2,E1,E3,E4);
                                                   >>  74 |
                                                   >>  75 - x = (T *)dma_alloc_coherent(E2,E1,E3,E4);
                                                   >>  76 + x = dma_zalloc_coherent(E2,E1,E3,E4);
                                                   >>  77 |
                                                   >>  78 - x = (T)dma_alloc_coherent(E2,E1,E3,E4);
                                                   >>  79 + x = (T)dma_zalloc_coherent(E2,E1,E3,E4);
                                                   >>  80 |
 73 - x = kmalloc_node(E1,E2,E3);                      81 - x = kmalloc_node(E1,E2,E3);
 74 + x = kzalloc_node(E1,E2,E3);                      82 + x = kzalloc_node(E1,E2,E3);
 75 |                                                  83 |
 76 - x = (T *)kmalloc_node(E1,E2,E3);                 84 - x = (T *)kmalloc_node(E1,E2,E3);
 77 + x = kzalloc_node(E1,E2,E3);                      85 + x = kzalloc_node(E1,E2,E3);
 78 |                                                  86 |
 79 - x = (T)kmalloc_node(E1,E2,E3);                   87 - x = (T)kmalloc_node(E1,E2,E3);
 80 + x = (T)kzalloc_node(E1,E2,E3);                   88 + x = (T)kzalloc_node(E1,E2,E3);
 81 |                                                  89 |
 82 - x = kmem_cache_alloc(E3,E4);                     90 - x = kmem_cache_alloc(E3,E4);
 83 + x = kmem_cache_zalloc(E3,E4);                    91 + x = kmem_cache_zalloc(E3,E4);
 84 |                                                  92 |
 85 - x = (T *)kmem_cache_alloc(E3,E4);                93 - x = (T *)kmem_cache_alloc(E3,E4);
 86 + x = kmem_cache_zalloc(E3,E4);                    94 + x = kmem_cache_zalloc(E3,E4);
 87 |                                                  95 |
 88 - x = (T)kmem_cache_alloc(E3,E4);                  96 - x = (T)kmem_cache_alloc(E3,E4);
 89 + x = (T)kmem_cache_zalloc(E3,E4);                 97 + x = (T)kmem_cache_zalloc(E3,E4);
 90 |                                                  98 |
 91 - x = kmem_alloc(E1,E2);                           99 - x = kmem_alloc(E1,E2);
 92 + x = kmem_zalloc(E1,E2);                         100 + x = kmem_zalloc(E1,E2);
 93 |                                                 101 |
 94 - x = (T *)kmem_alloc(E1,E2);                     102 - x = (T *)kmem_alloc(E1,E2);
 95 + x = kmem_zalloc(E1,E2);                         103 + x = kmem_zalloc(E1,E2);
 96 |                                                 104 |
 97 - x = (T)kmem_alloc(E1,E2);                       105 - x = (T)kmem_alloc(E1,E2);
 98 + x = (T)kmem_zalloc(E1,E2);                      106 + x = (T)kmem_zalloc(E1,E2);
 99 |                                                 107 |
100 - x = devm_kmalloc(E2,E1,E3);                     108 - x = devm_kmalloc(E2,E1,E3);
101 + x = devm_kzalloc(E2,E1,E3);                     109 + x = devm_kzalloc(E2,E1,E3);
102 |                                                 110 |
103 - x = (T *)devm_kmalloc(E2,E1,E3);                111 - x = (T *)devm_kmalloc(E2,E1,E3);
104 + x = devm_kzalloc(E2,E1,E3);                     112 + x = devm_kzalloc(E2,E1,E3);
105 |                                                 113 |
106 - x = (T)devm_kmalloc(E2,E1,E3);                  114 - x = (T)devm_kmalloc(E2,E1,E3);
107 + x = (T)devm_kzalloc(E2,E1,E3);                  115 + x = (T)devm_kzalloc(E2,E1,E3);
108 |                                                 116 |
109 - x = kvmalloc(E1,E2);                            117 - x = kvmalloc(E1,E2);
110 + x = kvzalloc(E1,E2);                            118 + x = kvzalloc(E1,E2);
111 |                                                 119 |
112 - x = (T *)kvmalloc(E1,E2);                       120 - x = (T *)kvmalloc(E1,E2);
113 + x = kvzalloc(E1,E2);                            121 + x = kvzalloc(E1,E2);
114 |                                                 122 |
115 - x = (T)kvmalloc(E1,E2);                         123 - x = (T)kvmalloc(E1,E2);
116 + x = (T)kvzalloc(E1,E2);                         124 + x = (T)kvzalloc(E1,E2);
117 |                                                 125 |
118 - x = kvmalloc_node(E1,E2,E3);                    126 - x = kvmalloc_node(E1,E2,E3);
119 + x = kvzalloc_node(E1,E2,E3);                    127 + x = kvzalloc_node(E1,E2,E3);
120 |                                                 128 |
121 - x = (T *)kvmalloc_node(E1,E2,E3);               129 - x = (T *)kvmalloc_node(E1,E2,E3);
122 + x = kvzalloc_node(E1,E2,E3);                    130 + x = kvzalloc_node(E1,E2,E3);
123 |                                                 131 |
124 - x = (T)kvmalloc_node(E1,E2,E3);                 132 - x = (T)kvmalloc_node(E1,E2,E3);
125 + x = (T)kvzalloc_node(E1,E2,E3);                 133 + x = (T)kvzalloc_node(E1,E2,E3);
126 )                                                 134 )
127   if ((x==NULL) || ...) S                         135   if ((x==NULL) || ...) S
128 - memset((T2)x,0,E1);                             136 - memset((T2)x,0,E1);
129                                                   137 
130 @depends on patch@                             << 
131 type T, T2;                                    << 
132 expression x;                                  << 
133 expression E1,E2,E3,E4;                        << 
134 statement S;                                   << 
135 @@                                             << 
136   x = (T)dma_alloc_coherent(E1, E2, E3, E4);   << 
137   if ((x==NULL) || ...) S                      << 
138 - memset((T2)x, 0, E2);                        << 
139                                                << 
140 //--------------------------------------------    138 //----------------------------------------------------------
141 //  For org mode                                  139 //  For org mode
142 //--------------------------------------------    140 //----------------------------------------------------------
143                                                   141 
144 @r depends on org || report@                      142 @r depends on org || report@
145 type T, T2;                                       143 type T, T2;
146 expression x;                                     144 expression x;
147 expression E1,E2;                                 145 expression E1,E2;
148 statement S;                                      146 statement S;
149 position p;                                       147 position p;
150 @@                                                148 @@
151                                                   149 
152  x = (T)kmalloc@p(E1,E2);                         150  x = (T)kmalloc@p(E1,E2);
153  if ((x==NULL) || ...) S                          151  if ((x==NULL) || ...) S
154  memset((T2)x,0,E1);                              152  memset((T2)x,0,E1);
155                                                   153 
156 @script:python depends on org@                    154 @script:python depends on org@
157 p << r.p;                                         155 p << r.p;
158 x << r.x;                                         156 x << r.x;
159 @@                                                157 @@
160                                                   158 
161 msg="%s" % (x)                                    159 msg="%s" % (x)
162 msg_safe=msg.replace("[","@(").replace("]",")"    160 msg_safe=msg.replace("[","@(").replace("]",")")
163 coccilib.org.print_todo(p[0], msg_safe)           161 coccilib.org.print_todo(p[0], msg_safe)
164                                                   162 
165 @script:python depends on report@                 163 @script:python depends on report@
166 p << r.p;                                         164 p << r.p;
167 x << r.x;                                         165 x << r.x;
168 @@                                                166 @@
169                                                   167 
170 msg="WARNING: kzalloc should be used for %s, i    168 msg="WARNING: kzalloc should be used for %s, instead of kmalloc/memset" % (x)
171 coccilib.report.print_report(p[0], msg)           169 coccilib.report.print_report(p[0], msg)
172                                                   170 
173 //--------------------------------------------    171 //-----------------------------------------------------------------
174 @r1 depends on org || report@                     172 @r1 depends on org || report@
175 type T, T2;                                       173 type T, T2;
176 expression x;                                     174 expression x;
177 expression E1;                                    175 expression E1;
178 statement S;                                      176 statement S;
179 position p;                                       177 position p;
180 @@                                                178 @@
181                                                   179 
182  x = (T)vmalloc@p(E1);                            180  x = (T)vmalloc@p(E1);
183  if ((x==NULL) || ...) S                          181  if ((x==NULL) || ...) S
184  memset((T2)x,0,E1);                              182  memset((T2)x,0,E1);
185                                                   183 
186 @script:python depends on org@                    184 @script:python depends on org@
187 p << r1.p;                                        185 p << r1.p;
188 x << r1.x;                                        186 x << r1.x;
189 @@                                                187 @@
190                                                   188 
191 msg="%s" % (x)                                    189 msg="%s" % (x)
192 msg_safe=msg.replace("[","@(").replace("]",")"    190 msg_safe=msg.replace("[","@(").replace("]",")")
193 coccilib.org.print_todo(p[0], msg_safe)           191 coccilib.org.print_todo(p[0], msg_safe)
194                                                   192 
195 @script:python depends on report@                 193 @script:python depends on report@
196 p << r1.p;                                        194 p << r1.p;
197 x << r1.x;                                        195 x << r1.x;
198 @@                                                196 @@
199                                                   197 
200 msg="WARNING: vzalloc should be used for %s, i    198 msg="WARNING: vzalloc should be used for %s, instead of vmalloc/memset" % (x)
201 coccilib.report.print_report(p[0], msg)           199 coccilib.report.print_report(p[0], msg)
202                                                   200 
203 //--------------------------------------------    201 //-----------------------------------------------------------------
204 @r2 depends on org || report@                     202 @r2 depends on org || report@
205 type T, T2;                                       203 type T, T2;
206 expression x;                                     204 expression x;
207 expression E1,E2,E3,E4;                           205 expression E1,E2,E3,E4;
208 statement S;                                      206 statement S;
209 position p;                                       207 position p;
210 @@                                                208 @@
211                                                   209 
212  x = (T)dma_alloc_coherent@p(E1,E2,E3,E4);     !! 210  x = (T)dma_alloc_coherent@p(E2,E1,E3,E4);
213  if ((x==NULL) || ...) S                          211  if ((x==NULL) || ...) S
214  memset((T2)x,0,E2);                           !! 212  memset((T2)x,0,E1);
215                                                   213 
216 @script:python depends on org@                    214 @script:python depends on org@
217 p << r2.p;                                        215 p << r2.p;
218 x << r2.x;                                        216 x << r2.x;
219 @@                                                217 @@
220                                                   218 
221 msg="%s" % (x)                                    219 msg="%s" % (x)
222 msg_safe=msg.replace("[","@(").replace("]",")"    220 msg_safe=msg.replace("[","@(").replace("]",")")
223 coccilib.org.print_todo(p[0], msg_safe)           221 coccilib.org.print_todo(p[0], msg_safe)
224                                                   222 
225 @script:python depends on report@                 223 @script:python depends on report@
226 p << r2.p;                                        224 p << r2.p;
227 x << r2.x;                                        225 x << r2.x;
228 @@                                                226 @@
229                                                   227 
230 msg="WARNING: dma_alloc_coherent used in %s al !! 228 msg="WARNING: dma_zalloc_coherent should be used for %s, instead of dma_alloc_coherent/memset" % (x)
231 coccilib.report.print_report(p[0], msg)           229 coccilib.report.print_report(p[0], msg)
232                                                   230 
233 //--------------------------------------------    231 //-----------------------------------------------------------------
234 @r3 depends on org || report@                     232 @r3 depends on org || report@
235 type T, T2;                                       233 type T, T2;
236 expression x;                                     234 expression x;
237 expression E1,E2,E3;                              235 expression E1,E2,E3;
238 statement S;                                      236 statement S;
239 position p;                                       237 position p;
240 @@                                                238 @@
241                                                   239 
242  x = (T)kmalloc_node@p(E1,E2,E3);                 240  x = (T)kmalloc_node@p(E1,E2,E3);
243  if ((x==NULL) || ...) S                          241  if ((x==NULL) || ...) S
244  memset((T2)x,0,E1);                              242  memset((T2)x,0,E1);
245                                                   243 
246 @script:python depends on org@                    244 @script:python depends on org@
247 p << r3.p;                                        245 p << r3.p;
248 x << r3.x;                                        246 x << r3.x;
249 @@                                                247 @@
250                                                   248 
251 msg="%s" % (x)                                    249 msg="%s" % (x)
252 msg_safe=msg.replace("[","@(").replace("]",")"    250 msg_safe=msg.replace("[","@(").replace("]",")")
253 coccilib.org.print_todo(p[0], msg_safe)           251 coccilib.org.print_todo(p[0], msg_safe)
254                                                   252 
255 @script:python depends on report@                 253 @script:python depends on report@
256 p << r3.p;                                        254 p << r3.p;
257 x << r3.x;                                        255 x << r3.x;
258 @@                                                256 @@
259                                                   257 
260 msg="WARNING: kzalloc_node should be used for     258 msg="WARNING: kzalloc_node should be used for %s, instead of kmalloc_node/memset" % (x)
261 coccilib.report.print_report(p[0], msg)           259 coccilib.report.print_report(p[0], msg)
262                                                   260 
263 //--------------------------------------------    261 //-----------------------------------------------------------------
264 @r4 depends on org || report@                     262 @r4 depends on org || report@
265 type T, T2;                                       263 type T, T2;
266 expression x;                                     264 expression x;
267 expression E1,E2,E3;                              265 expression E1,E2,E3;
268 statement S;                                      266 statement S;
269 position p;                                       267 position p;
270 @@                                                268 @@
271                                                   269 
272  x = (T)kmem_cache_alloc@p(E2,E3);                270  x = (T)kmem_cache_alloc@p(E2,E3);
273  if ((x==NULL) || ...) S                          271  if ((x==NULL) || ...) S
274  memset((T2)x,0,E1);                              272  memset((T2)x,0,E1);
275                                                   273 
276 @script:python depends on org@                    274 @script:python depends on org@
277 p << r4.p;                                        275 p << r4.p;
278 x << r4.x;                                        276 x << r4.x;
279 @@                                                277 @@
280                                                   278 
281 msg="%s" % (x)                                    279 msg="%s" % (x)
282 msg_safe=msg.replace("[","@(").replace("]",")"    280 msg_safe=msg.replace("[","@(").replace("]",")")
283 coccilib.org.print_todo(p[0], msg_safe)           281 coccilib.org.print_todo(p[0], msg_safe)
284                                                   282 
285 @script:python depends on report@                 283 @script:python depends on report@
286 p << r4.p;                                        284 p << r4.p;
287 x << r4.x;                                        285 x << r4.x;
288 @@                                                286 @@
289                                                   287 
290 msg="WARNING: kmem_cache_zalloc should be used    288 msg="WARNING: kmem_cache_zalloc should be used for %s, instead of kmem_cache_alloc/memset" % (x)
291 coccilib.report.print_report(p[0], msg)           289 coccilib.report.print_report(p[0], msg)
292                                                   290 
293 //--------------------------------------------    291 //-----------------------------------------------------------------
294 @r5 depends on org || report@                     292 @r5 depends on org || report@
295 type T, T2;                                       293 type T, T2;
296 expression x;                                     294 expression x;
297 expression E1,E2;                                 295 expression E1,E2;
298 statement S;                                      296 statement S;
299 position p;                                       297 position p;
300 @@                                                298 @@
301                                                   299 
302  x = (T)kmem_alloc@p(E1,E2);                      300  x = (T)kmem_alloc@p(E1,E2);
303  if ((x==NULL) || ...) S                          301  if ((x==NULL) || ...) S
304  memset((T2)x,0,E1);                              302  memset((T2)x,0,E1);
305                                                   303 
306 @script:python depends on org@                    304 @script:python depends on org@
307 p << r5.p;                                        305 p << r5.p;
308 x << r5.x;                                        306 x << r5.x;
309 @@                                                307 @@
310                                                   308 
311 msg="%s" % (x)                                    309 msg="%s" % (x)
312 msg_safe=msg.replace("[","@(").replace("]",")"    310 msg_safe=msg.replace("[","@(").replace("]",")")
313 coccilib.org.print_todo(p[0], msg_safe)           311 coccilib.org.print_todo(p[0], msg_safe)
314                                                   312 
315 @script:python depends on report@                 313 @script:python depends on report@
316 p << r5.p;                                        314 p << r5.p;
317 x << r5.x;                                        315 x << r5.x;
318 @@                                                316 @@
319                                                   317 
320 msg="WARNING: kmem_zalloc should be used for %    318 msg="WARNING: kmem_zalloc should be used for %s, instead of kmem_alloc/memset" % (x)
321 coccilib.report.print_report(p[0], msg)           319 coccilib.report.print_report(p[0], msg)
322                                                   320 
323 //--------------------------------------------    321 //-----------------------------------------------------------------
324 @r6 depends on org || report@                     322 @r6 depends on org || report@
325 type T, T2;                                       323 type T, T2;
326 expression x;                                     324 expression x;
327 expression E1,E2,E3;                              325 expression E1,E2,E3;
328 statement S;                                      326 statement S;
329 position p;                                       327 position p;
330 @@                                                328 @@
331                                                   329 
332  x = (T)devm_kmalloc@p(E2,E1,E3);                 330  x = (T)devm_kmalloc@p(E2,E1,E3);
333  if ((x==NULL) || ...) S                          331  if ((x==NULL) || ...) S
334  memset((T2)x,0,E1);                              332  memset((T2)x,0,E1);
335                                                   333 
336 @script:python depends on org@                    334 @script:python depends on org@
337 p << r6.p;                                        335 p << r6.p;
338 x << r6.x;                                        336 x << r6.x;
339 @@                                                337 @@
340                                                   338 
341 msg="%s" % (x)                                    339 msg="%s" % (x)
342 msg_safe=msg.replace("[","@(").replace("]",")"    340 msg_safe=msg.replace("[","@(").replace("]",")")
343 coccilib.org.print_todo(p[0], msg_safe)           341 coccilib.org.print_todo(p[0], msg_safe)
344                                                   342 
345 @script:python depends on report@                 343 @script:python depends on report@
346 p << r6.p;                                        344 p << r6.p;
347 x << r6.x;                                        345 x << r6.x;
348 @@                                                346 @@
349                                                   347 
350 msg="WARNING: devm_kzalloc should be used for     348 msg="WARNING: devm_kzalloc should be used for %s, instead of devm_kmalloc/memset" % (x)
351 coccilib.report.print_report(p[0], msg)           349 coccilib.report.print_report(p[0], msg)
352                                                   350 
353 //--------------------------------------------    351 //-----------------------------------------------------------------
354 @r7 depends on org || report@                     352 @r7 depends on org || report@
355 type T, T2;                                       353 type T, T2;
356 expression x;                                     354 expression x;
357 expression E1,E2;                                 355 expression E1,E2;
358 statement S;                                      356 statement S;
359 position p;                                       357 position p;
360 @@                                                358 @@
361                                                   359 
362  x = (T)kvmalloc@p(E1,E2);                        360  x = (T)kvmalloc@p(E1,E2);
363  if ((x==NULL) || ...) S                          361  if ((x==NULL) || ...) S
364  memset((T2)x,0,E1);                              362  memset((T2)x,0,E1);
365                                                   363 
366 @script:python depends on org@                    364 @script:python depends on org@
367 p << r7.p;                                        365 p << r7.p;
368 x << r7.x;                                        366 x << r7.x;
369 @@                                                367 @@
370                                                   368 
371 msg="%s" % (x)                                    369 msg="%s" % (x)
372 msg_safe=msg.replace("[","@(").replace("]",")"    370 msg_safe=msg.replace("[","@(").replace("]",")")
373 coccilib.org.print_todo(p[0], msg_safe)           371 coccilib.org.print_todo(p[0], msg_safe)
374                                                   372 
375 @script:python depends on report@                 373 @script:python depends on report@
376 p << r7.p;                                        374 p << r7.p;
377 x << r7.x;                                        375 x << r7.x;
378 @@                                                376 @@
379                                                   377 
380 msg="WARNING: kvzalloc should be used for %s,     378 msg="WARNING: kvzalloc should be used for %s, instead of kvmalloc/memset" % (x)
381 coccilib.report.print_report(p[0], msg)           379 coccilib.report.print_report(p[0], msg)
382                                                   380 
383 //--------------------------------------------    381 //-----------------------------------------------------------------
384 @r9 depends on org || report@                     382 @r9 depends on org || report@
385 type T, T2;                                       383 type T, T2;
386 expression x;                                     384 expression x;
387 expression E1,E2,E3;                              385 expression E1,E2,E3;
388 statement S;                                      386 statement S;
389 position p;                                       387 position p;
390 @@                                                388 @@
391                                                   389 
392  x = (T)kvmalloc_node@p(E1,E2,E3);                390  x = (T)kvmalloc_node@p(E1,E2,E3);
393  if ((x==NULL) || ...) S                          391  if ((x==NULL) || ...) S
394  memset((T2)x,0,E1);                              392  memset((T2)x,0,E1);
395                                                   393 
396 @script:python depends on org@                    394 @script:python depends on org@
397 p << r9.p;                                        395 p << r9.p;
398 x << r9.x;                                        396 x << r9.x;
399 @@                                                397 @@
400                                                   398 
401 msg="%s" % (x)                                    399 msg="%s" % (x)
402 msg_safe=msg.replace("[","@(").replace("]",")"    400 msg_safe=msg.replace("[","@(").replace("]",")")
403 coccilib.org.print_todo(p[0], msg_safe)           401 coccilib.org.print_todo(p[0], msg_safe)
404                                                   402 
405 @script:python depends on report@                 403 @script:python depends on report@
406 p << r9.p;                                        404 p << r9.p;
407 x << r9.x;                                        405 x << r9.x;
408 @@                                                406 @@
409                                                   407 
410 msg="WARNING: kvzalloc_node should be used for    408 msg="WARNING: kvzalloc_node should be used for %s, instead of kvmalloc_node/memset" % (x)
411 coccilib.report.print_report(p[0], msg)           409 coccilib.report.print_report(p[0], msg)
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php