1f7b16711Sstrnape1@fel.cvut.cz/// Find missing pci_free_consistent for every pci_alloc_consistent.
2f7b16711Sstrnape1@fel.cvut.cz///
3f7b16711Sstrnape1@fel.cvut.cz// Confidence: Moderate
4f7b16711Sstrnape1@fel.cvut.cz// Copyright: (C) 2013 Petr Strnad.  GPLv2.
5f7b16711Sstrnape1@fel.cvut.cz// URL: http://coccinelle.lip6.fr/
6f7b16711Sstrnape1@fel.cvut.cz// Keywords: pci_free_consistent, pci_alloc_consistent
7f7b16711Sstrnape1@fel.cvut.cz// Options: --no-includes --include-headers
8f7b16711Sstrnape1@fel.cvut.cz
9f7b16711Sstrnape1@fel.cvut.czvirtual report
10f7b16711Sstrnape1@fel.cvut.czvirtual org
11f7b16711Sstrnape1@fel.cvut.cz
12f7b16711Sstrnape1@fel.cvut.cz@search@
13f7b16711Sstrnape1@fel.cvut.czlocal idexpression id;
14f7b16711Sstrnape1@fel.cvut.czexpression x,y,z,e;
15f7b16711Sstrnape1@fel.cvut.czposition p1,p2;
16f7b16711Sstrnape1@fel.cvut.cztype T;
17f7b16711Sstrnape1@fel.cvut.cz@@
18f7b16711Sstrnape1@fel.cvut.cz
19f7b16711Sstrnape1@fel.cvut.czid = pci_alloc_consistent@p1(x,y,&z)
20f7b16711Sstrnape1@fel.cvut.cz... when != e = id
21f7b16711Sstrnape1@fel.cvut.czif (id == NULL || ...) { ... return ...; }
22f7b16711Sstrnape1@fel.cvut.cz... when != pci_free_consistent(x,y,id,z)
23f7b16711Sstrnape1@fel.cvut.cz    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
24f7b16711Sstrnape1@fel.cvut.cz    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
25f7b16711Sstrnape1@fel.cvut.cz    when != e = (T)id
26f7b16711Sstrnape1@fel.cvut.cz    when exists
27f7b16711Sstrnape1@fel.cvut.cz(
28f7b16711Sstrnape1@fel.cvut.czreturn 0;
29f7b16711Sstrnape1@fel.cvut.cz|
30f7b16711Sstrnape1@fel.cvut.czreturn 1;
31f7b16711Sstrnape1@fel.cvut.cz|
32f7b16711Sstrnape1@fel.cvut.czreturn id;
33f7b16711Sstrnape1@fel.cvut.cz|
34f7b16711Sstrnape1@fel.cvut.czreturn@p2 ...;
35f7b16711Sstrnape1@fel.cvut.cz)
36f7b16711Sstrnape1@fel.cvut.cz
37f7b16711Sstrnape1@fel.cvut.cz@script:python depends on report@
38f7b16711Sstrnape1@fel.cvut.czp1 << search.p1;
39f7b16711Sstrnape1@fel.cvut.czp2 << search.p2;
40f7b16711Sstrnape1@fel.cvut.cz@@
41f7b16711Sstrnape1@fel.cvut.cz
42f7b16711Sstrnape1@fel.cvut.czmsg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
43f7b16711Sstrnape1@fel.cvut.czcoccilib.report.print_report(p2[0],msg)
44f7b16711Sstrnape1@fel.cvut.cz
45f7b16711Sstrnape1@fel.cvut.cz@script:python depends on org@
46f7b16711Sstrnape1@fel.cvut.czp1 << search.p1;
47f7b16711Sstrnape1@fel.cvut.czp2 << search.p2;
48f7b16711Sstrnape1@fel.cvut.cz@@
49f7b16711Sstrnape1@fel.cvut.cz
50f7b16711Sstrnape1@fel.cvut.czmsg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
51f7b16711Sstrnape1@fel.cvut.czcocci.print_main(msg,p1)
52f7b16711Sstrnape1@fel.cvut.czcocci.print_secs("",p2)
53