Release coccinelle-0.2.0rc1
[bpt/coccinelle.git] / scripts / coccicheck / cocci / kzmem.cocci
1 // Remove useless call to memset for zeroing memory
2 // after a kzalloc call.
3 //
4 // Confidence:
5 // Copyright: (C) Gilles Muller, Julia Lawall, EMN, DIKU. GPLv2.
6 // URL: http://coccinelle.lip6.fr/
7 // Options:
8
9 virtual org,patch,diff
10
11 @depends on patch && !org && !diff@
12 expression x;
13 statement S;
14 @@
15
16 x = kzalloc(...);
17 if (x == NULL) S
18 ... when != x
19 -memset(x,0,...);
20
21 @depends on !patch && !org && diff@
22 expression x;
23 statement S;
24 @@
25
26 x = kzalloc(...);
27 if (x == NULL) S
28 ... when != x
29 *memset(x,0,...);
30
31 @r depends on !patch && org && !diff@
32 expression x;
33 statement S;
34 position p;
35 @@
36
37 x = kzalloc(...);
38 if (x == NULL) S
39 ... when != x
40 memset@p(x,0,...);
41
42 @script:python depends on org@
43 p << r.p;
44 @@
45
46 msg="%s:%s" % (p[0].file, p[0].line)
47 cocci.print_main(msg, p)