Skip to content

Commit

Permalink
Coccinelle: remove pci_alloc_consistent semantic to detect in zalloc-…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
Acked-by: Himanshu Jha <[email protected]>
Signed-off-by: zhong jiang <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
xiongzhongjiang authored and masahir0y committed Aug 22, 2018
1 parent f55f232 commit 6fbd856
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions scripts/coccinelle/api/alloc/zalloc-simple.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ statement S;

* x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|pci_alloc_consistent(...,E1,...)\|
kvmalloc_node(E1,...)\);
devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|kvmalloc_node(E1,...)\);
if ((x==NULL) || ...) S
* memset((T2)x,0,E1);

Expand Down Expand Up @@ -124,15 +123,6 @@ statement S;
- x = (T)kvmalloc(E1,E2);
+ x = (T)kvzalloc(E1,E2);
|
- x = pci_alloc_consistent(E2,E1,E3);
+ x = pci_zalloc_consistent(E2,E1,E3);
|
- x = (T *)pci_alloc_consistent(E2,E1,E3);
+ x = pci_zalloc_consistent(E2,E1,E3);
|
- x = (T)pci_alloc_consistent(E2,E1,E3);
+ x = (T)pci_zalloc_consistent(E2,E1,E3);
|
- x = kvmalloc_node(E1,E2,E3);
+ x = kvzalloc_node(E1,E2,E3);
|
Expand Down Expand Up @@ -388,35 +378,6 @@ x << r7.x;
msg="WARNING: kvzalloc should be used for %s, instead of kvmalloc/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r8 depends on org || report@
type T, T2;
expression x;
expression E1,E2,E3;
statement S;
position p;
@@

x = (T)pci_alloc_consistent@p(E2,E1,E3);
if ((x==NULL) || ...) S
memset((T2)x,0,E1);

@script:python depends on org@
p << r8.p;
x << r8.x;
@@
msg="%s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)
@script:python depends on report@
p << r8.p;
x << r8.x;
@@
msg="WARNING: pci_zalloc_consistent should be used for %s, instead of pci_alloc_consistent/memset" % (x)
coccilib.report.print_report(p[0], msg)
//-----------------------------------------------------------------
@r9 depends on org || report@
type T, T2;
Expand Down

0 comments on commit 6fbd856

Please sign in to comment.