2 /// Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0
4 // Copyright: (C) 2015 Intel Corp. GPLv2.
5 // Options: --no-includes --include-headers
7 // Keywords: dma_pool_zalloc, pci_pool_zalloc
15 //----------------------------------------------------------
17 //----------------------------------------------------------
24 * x = \(dma_pool_alloc\|pci_pool_alloc\)(...);
25 if ((x==NULL) || ...) S
28 //----------------------------------------------------------
30 //----------------------------------------------------------
38 - x = dma_pool_alloc(a,b,c);
39 + x = dma_pool_zalloc(a,b,c);
40 if ((x==NULL) || ...) S
49 - x = pci_pool_alloc(a,b,c);
50 + x = pci_pool_zalloc(a,b,c);
51 if ((x==NULL) || ...) S
54 //----------------------------------------------------------
55 // For org and report mode
56 //----------------------------------------------------------
58 @r depends on org || report@
65 x = @p\(dma_pool_alloc\|pci_pool_alloc\)(a,b,c);
66 if ((x==NULL) || ...) S
69 @script:python depends on org@
75 msg_safe=msg.replace("[","@(").replace("]",")")
76 coccilib.org.print_todo(p[0], msg_safe)
78 @script:python depends on report@
83 msg="WARNING: *_pool_zalloc should be used for %s, instead of *_pool_alloc/memset" % (x)
84 coccilib.report.print_report(p[0], msg)