* [PATCHv2] Coccinelle: remove pci_alloc_consistent semantic to detect in zalloc-simple.cocci
@ 2018-08-18 13:51 zhong jiang
2018-08-19 9:01 ` Masahiro Yamada
0 siblings, 1 reply; 2+ messages in thread
From: zhong jiang @ 2018-08-18 13:51 UTC (permalink / raw)
To: yamada.masahiro
Cc: Julia.Lawall, himanshujha199640, Gilles.Muller, nicolas.palix,
michal.lkml, linux-kernel
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>
---
v1->v2:
- fix some spelling mistakes.
scripts/coccinelle/api/alloc/zalloc-simple.cocci | 41 +-----------------------
1 file changed, 1 insertion(+), 40 deletions(-)
diff --git a/scripts/coccinelle/api/alloc/zalloc-simple.cocci b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
index 92b2091..d819275 100644
--- a/scripts/coccinelle/api/alloc/zalloc-simple.cocci
+++ b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
@@ -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);
@@ -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);
|
@@ -389,35 +379,6 @@ 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;
expression x;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv2] Coccinelle: remove pci_alloc_consistent semantic to detect in zalloc-simple.cocci
2018-08-18 13:51 [PATCHv2] Coccinelle: remove pci_alloc_consistent semantic to detect in zalloc-simple.cocci zhong jiang
@ 2018-08-19 9:01 ` Masahiro Yamada
0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2018-08-19 9:01 UTC (permalink / raw)
To: zhong jiang
Cc: Julia Lawall, Himanshu Jha, Gilles Muller, Nicolas Palix,
Michal Marek, Linux Kernel Mailing List
2018-08-18 22:51 GMT+09:00 zhong jiang <zhongjiang@huawei.com>:
> 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>
> ---
> v1->v2:
> - fix some spelling mistakes.
Applied to linux-kbuild. Thanks!
> scripts/coccinelle/api/alloc/zalloc-simple.cocci | 41 +-----------------------
> 1 file changed, 1 insertion(+), 40 deletions(-)
>
> diff --git a/scripts/coccinelle/api/alloc/zalloc-simple.cocci b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
> index 92b2091..d819275 100644
> --- a/scripts/coccinelle/api/alloc/zalloc-simple.cocci
> +++ b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
> @@ -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);
>
> @@ -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);
> |
> @@ -389,35 +379,6 @@ 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;
> expression x;
> --
> 1.7.12.4
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-19 9:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-18 13:51 [PATCHv2] Coccinelle: remove pci_alloc_consistent semantic to detect in zalloc-simple.cocci zhong jiang
2018-08-19 9:01 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).