1/// 2/// Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0 3/// 4// Copyright: (C) 2015 Intel Corp. GPLv2. 5// Options: --no-includes --include-headers 6// 7// Keywords: dma_pool_zalloc, pci_pool_zalloc 8// 9 10virtual context 11virtual patch 12virtual org 13virtual report 14 15//---------------------------------------------------------- 16// For context mode 17//---------------------------------------------------------- 18 19@depends on context@ 20expression x; 21statement S; 22@@ 23 24* x = \(dma_pool_alloc\|pci_pool_alloc\)(...); 25 if ((x==NULL) || ...) S 26* memset(x,0, ...); 27 28//---------------------------------------------------------- 29// For patch mode 30//---------------------------------------------------------- 31 32@depends on patch@ 33expression x; 34expression a,b,c; 35statement S; 36@@ 37 38- x = dma_pool_alloc(a,b,c); 39+ x = dma_pool_zalloc(a,b,c); 40 if ((x==NULL) || ...) S 41- memset(x,0,...); 42 43@depends on patch@ 44expression x; 45expression a,b,c; 46statement S; 47@@ 48 49- x = pci_pool_alloc(a,b,c); 50+ x = pci_pool_zalloc(a,b,c); 51 if ((x==NULL) || ...) S 52- memset(x,0,...); 53 54//---------------------------------------------------------- 55// For org and report mode 56//---------------------------------------------------------- 57 58@r depends on org || report@ 59expression x; 60expression a,b,c; 61statement S; 62position p; 63@@ 64 65 x = @p\(dma_pool_alloc\|pci_pool_alloc\)(a,b,c); 66 if ((x==NULL) || ...) S 67 memset(x,0, ...); 68 69@script:python depends on org@ 70p << r.p; 71x << r.x; 72@@ 73 74msg="%s" % (x) 75msg_safe=msg.replace("[","@(").replace("]",")") 76coccilib.org.print_todo(p[0], msg_safe) 77 78@script:python depends on report@ 79p << r.p; 80x << r.x; 81@@ 82 83msg="WARNING: *_pool_zalloc should be used for %s, instead of *_pool_alloc/memset" % (x) 84coccilib.report.print_report(p[0], msg) 85