aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhong jiang <zhongjiang@huawei.com>2018-08-18 09:51:12 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-08-22 10:21:43 -0400
commit6fbd856950b41345ad5c893613efebdc0c356bc7 (patch)
tree462ca0f93bc3509f007e361c1286355c800951bf
parentf55f2328bb28a8517620518c5d124f5194673309 (diff)
Coccinelle: remove pci_alloc_consistent semantic to detect in zalloc-simple.cocci
Because pci_alloc_consistent has been deprecated. We prefer to use dma_alloc_coherent directly. Therefore, we should remove pci_alloc_consistent to increase the confidence. Acked-by: Julia Lawall <julia.lawall@lip6.fr> Acked-by: Himanshu Jha <himanshujha199640@gmail.com> Signed-off-by: zhong jiang <zhongjiang@huawei.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r--scripts/coccinelle/api/alloc/zalloc-simple.cocci41
1 files changed, 1 insertions, 40 deletions
diff --git a/scripts/coccinelle/api/alloc/zalloc-simple.cocci b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
index 92b20913055f..d819275b7fde 100644
--- a/scripts/coccinelle/api/alloc/zalloc-simple.cocci
+++ b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
@@ -35,8 +35,7 @@ statement S;
35 35
36* x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\| 36* x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
37 kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\| 37 kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
38 devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|pci_alloc_consistent(...,E1,...)\| 38 devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|kvmalloc_node(E1,...)\);
39 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
@@ -124,15 +123,6 @@ statement S;
124- x = (T)kvmalloc(E1,E2); 123- x = (T)kvmalloc(E1,E2);
125+ x = (T)kvzalloc(E1,E2); 124+ x = (T)kvzalloc(E1,E2);
126| 125|
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); 126- x = kvmalloc_node(E1,E2,E3);
137+ x = kvzalloc_node(E1,E2,E3); 127+ x = kvzalloc_node(E1,E2,E3);
138| 128|
@@ -389,35 +379,6 @@ msg="WARNING: kvzalloc should be used for %s, instead of kvmalloc/memset" % (x)
389coccilib.report.print_report(p[0], msg) 379coccilib.report.print_report(p[0], msg)
390 380
391//----------------------------------------------------------------- 381//-----------------------------------------------------------------
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@ 382@r9 depends on org || report@
422type T, T2; 383type T, T2;
423expression x; 384expression x;