Linux Audio

Check our new training course

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