diff options
author | zhong jiang <zhongjiang@huawei.com> | 2018-08-18 09:51:12 -0400 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-08-22 10:21:43 -0400 |
commit | 6fbd856950b41345ad5c893613efebdc0c356bc7 (patch) | |
tree | 462ca0f93bc3509f007e361c1286355c800951bf | |
parent | f55f2328bb28a8517620518c5d124f5194673309 (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.cocci | 41 |
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) | |||
389 | coccilib.report.print_report(p[0], msg) | 379 | coccilib.report.print_report(p[0], msg) |
390 | 380 | ||
391 | //----------------------------------------------------------------- | 381 | //----------------------------------------------------------------- |
392 | @r8 depends on org || report@ | ||
393 | type T, T2; | ||
394 | expression x; | ||
395 | expression E1,E2,E3; | ||
396 | statement S; | ||
397 | position 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@ | ||
405 | p << r8.p; | ||
406 | x << r8.x; | ||
407 | @@ | ||
408 | |||
409 | msg="%s" % (x) | ||
410 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
411 | coccilib.org.print_todo(p[0], msg_safe) | ||
412 | |||
413 | @script:python depends on report@ | ||
414 | p << r8.p; | ||
415 | x << r8.x; | ||
416 | @@ | ||
417 | |||
418 | msg="WARNING: pci_zalloc_consistent should be used for %s, instead of pci_alloc_consistent/memset" % (x) | ||
419 | coccilib.report.print_report(p[0], msg) | ||
420 | //----------------------------------------------------------------- | ||
421 | @r9 depends on org || report@ | 382 | @r9 depends on org || report@ |
422 | type T, T2; | 383 | type T, T2; |
423 | expression x; | 384 | expression x; |