1 /// Remove casting the values returned by memory allocation functions
2 /// like kmalloc, kzalloc, kmem_cache_alloc, kmem_cache_zalloc etc.
4 //# This makes an effort to find cases of casting of values returned by
5 //# kmalloc, kzalloc, kcalloc, kmem_cache_alloc, kmem_cache_zalloc,
6 //# kmem_cache_alloc_node, kmalloc_node and kzalloc_node and removes
7 //# the casting as it is not required. The result in the patch case may
8 //#need some reformatting.
11 // Copyright: 2014, Himangi Saraogi GPLv2.
13 // Options: --no-includes --include-headers
21 //----------------------------------------------------------
23 //----------------------------------------------------------
30 \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
31 kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...)
33 //----------------------------------------------------------
35 //----------------------------------------------------------
42 (\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
43 kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...))
45 //----------------------------------------------------------
46 // For org and report mode
47 //----------------------------------------------------------
49 @r depends on org || report@
54 (T@p *)\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
55 kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...)
57 @script:python depends on org@
62 coccilib.org.print_safe_todo(p[0], t)
64 @script:python depends on report@
69 msg="WARNING: casting value returned by memory allocation function to (%s *) is useless." % (t)
70 coccilib.report.print_report(p[0], msg)