2 /// kzalloc should be used rather than kmalloc followed by memset 0
5 // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2.
6 // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6. GPLv2.
7 // URL: http://coccinelle.lip6.fr/rules/kzalloc.html
8 // Options: -no_includes -include_headers
10 // Keywords: kmalloc, kzalloc
11 // Version min: < 2.6.12 kmalloc
12 // Version min: 2.6.14 kzalloc
20 //----------------------------------------------------------
22 //----------------------------------------------------------
31 * x = (T)kmalloc(E1,E2);
32 if ((x==NULL) || ...) S
35 //----------------------------------------------------------
37 //----------------------------------------------------------
46 - x = (T)kmalloc(E1,E2);
48 if ((x==NULL) || ...) S
51 //----------------------------------------------------------
53 //----------------------------------------------------------
55 @r depends on org || report@
63 x = (T)kmalloc@p(E1,E2);
64 if ((x==NULL) || ...) S
67 @script:python depends on org@
73 msg_safe=msg.replace("[","@(").replace("]",")")
74 coccilib.org.print_todo(p[0], msg_safe)
76 @script:python depends on report@
81 msg="WARNING: kzalloc should be used for %s, instead of kmalloc/memset" % (x)
82 coccilib.report.print_report(p[0], msg)