1 // SPDX-License-Identifier: GPL-2.0-only
3 /// Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0
5 // Copyright: (C) 2015 Intel Corp.
6 // Options: --no-includes --include-headers
8 // Keywords: dma_pool_zalloc, pci_pool_zalloc
16 //----------------------------------------------------------
18 //----------------------------------------------------------
25 * x = \(dma_pool_alloc\|pci_pool_alloc\)(...);
26 if ((x==NULL) || ...) S
29 //----------------------------------------------------------
31 //----------------------------------------------------------
39 - x = dma_pool_alloc(a,b,c);
40 + x = dma_pool_zalloc(a,b,c);
41 if ((x==NULL) || ...) S
50 - x = pci_pool_alloc(a,b,c);
51 + x = pci_pool_zalloc(a,b,c);
52 if ((x==NULL) || ...) S
55 //----------------------------------------------------------
56 // For org and report mode
57 //----------------------------------------------------------
59 @r depends on org || report@
66 x = @p\(dma_pool_alloc\|pci_pool_alloc\)(a,b,c);
67 if ((x==NULL) || ...) S
70 @script:python depends on org@
76 msg_safe=msg.replace("[","@(").replace("]",")")
77 coccilib.org.print_todo(p[0], msg_safe)
79 @script:python depends on report@
84 msg="WARNING: *_pool_zalloc should be used for %s, instead of *_pool_alloc/memset" % (x)
85 coccilib.report.print_report(p[0], msg)