Skip to content

Commit 6fbd856

Browse files
xiongzhongjiangmasahir0y
authored andcommitted
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>
1 parent f55f232 commit 6fbd856

1 file changed

Lines changed: 1 addition & 40 deletions

File tree

‎scripts/coccinelle/api/alloc/zalloc-simple.cocci‎

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ statement S;
3535

3636
* x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
3737
kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
38-
devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|pci_alloc_consistent(...,E1,...)\|
39-
kvmalloc_node(E1,...)\);
38+
devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|kvmalloc_node(E1,...)\);
4039
if ((x==NULL) || ...) S
4140
* memset((T2)x,0,E1);
4241

@@ -124,15 +123,6 @@ statement S;
124123
- x = (T)kvmalloc(E1,E2);
125124
+ x = (T)kvzalloc(E1,E2);
126125
|
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-
|
136126
- x = kvmalloc_node(E1,E2,E3);
137127
+ x = kvzalloc_node(E1,E2,E3);
138128
|
@@ -388,35 +378,6 @@ x << r7.x;
388378
msg="WARNING: kvzalloc should be used for %s, instead of kvmalloc/memset" % (x)
389379
coccilib.report.print_report(p[0], msg)
390380
391-
//-----------------------------------------------------------------
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)
420381
//-----------------------------------------------------------------
421382
@r9 depends on org || report@
422383
type T, T2;

0 commit comments

Comments
 (0)