~ubuntu-branches/ubuntu/trusty/coccinelle/trusty-proposed

« back to all changes in this revision

Viewing changes to scripts/coccicheck/cocci/kmalloc7.cocci

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2010-01-31 22:30:19 UTC
  • mfrom: (7.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100131223019-hbq02ip17tn17n52
Tags: 0.2.0.deb-1ubuntu1
* Merge from debian testing (LP: #515198).Remaining changes:
  - debian/control: build-depend on python2.6-dev,
    set XB-Python-Version to 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// kmalloc 7
 
3
//
 
4
//
 
5
 
 
6
virtual org,diff
 
7
 
 
8
@r exists@
 
9
local idexpression x;
 
10
statement S;
 
11
expression E;
 
12
identifier f,l;
 
13
position p1,p2,p3;
 
14
expression *ptr != NULL;
 
15
@@
 
16
 
 
17
(
 
18
if ((x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...)) == NULL) S
 
19
|
 
20
x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
 
21
...
 
22
if (x == NULL) S
 
23
)
 
24
<... when != x
 
25
     when != if (...) { <+...x...+> }
 
26
(
 
27
goto@p3 l;
 
28
|
 
29
x->f = E
 
30
)
 
31
...>
 
32
(
 
33
 return \(0\|<+...x...+>\|ptr\);
 
34
|
 
35
 return@p2 ...;
 
36
)
 
37
 
 
38
@script:python depends on org@
 
39
p1 << r.p1;
 
40
p2 << r.p2;
 
41
p3 << r.p3;
 
42
@@
 
43
 
 
44
cocci.print_main("",p1)
 
45
cocci.print_secs("", p2)
 
46
cocci.print_secs("goto", p3)
 
47
cocci.include_match(False)
 
48
 
 
49
@script:python depends on org@
 
50
p1 << r.p1;
 
51
p2 << r.p2;
 
52
@@
 
53
 
 
54
cocci.print_main("",p1)
 
55
cocci.print_secs("", p2)
 
56
 
 
57
@with_goto depends on diff@
 
58
expression x;
 
59
identifier l;
 
60
position r.p1, r.p2, r.p3;
 
61
@@
 
62
 
 
63
*x@p1
 
64
<...
 
65
*goto@p3 l;
 
66
...>
 
67
*return@p2 ...;