Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) ///
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) /// Use zeroing allocator rather than allocator followed by memset with 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) ///
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) /// This considers some simple cases that are common and easy to validate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) /// Note in particular that there are no ...s in the rule, so all of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) /// matched code has to be contiguous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) ///
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) // Confidence: High
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) // Copyright: (C) 2017 Himanshu Jha
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) // URL: http://coccinelle.lip6.fr/rules/kzalloc.html
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) // Options: --no-includes --include-headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) // Keywords: kmalloc, kzalloc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) // Version min: < 2.6.12 kmalloc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) // Version min:   2.6.14 kzalloc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) virtual context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) virtual patch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) virtual org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) virtual report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) //----------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) //  For context mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) //----------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) @depends on context@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) expression E1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) * x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)   kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)   devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|kvmalloc_node(E1,...)\);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)   if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) * memset((T2)x,0,E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) //----------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) //  For patch mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) //----------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) @depends on patch@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) expression E1,E2,E3,E4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) - x = kmalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) + x = kzalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) - x = (T *)kmalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) + x = kzalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) - x = (T)kmalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) + x = (T)kzalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) - x = vmalloc(E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) + x = vzalloc(E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) - x = (T *)vmalloc(E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) + x = vzalloc(E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) - x = (T)vmalloc(E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) + x = (T)vzalloc(E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) - x = kmalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) + x = kzalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) - x = (T *)kmalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) + x = kzalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) - x = (T)kmalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) + x = (T)kzalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) - x = kmem_cache_alloc(E3,E4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) + x = kmem_cache_zalloc(E3,E4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) - x = (T *)kmem_cache_alloc(E3,E4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) + x = kmem_cache_zalloc(E3,E4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) - x = (T)kmem_cache_alloc(E3,E4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) + x = (T)kmem_cache_zalloc(E3,E4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) - x = kmem_alloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) + x = kmem_zalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) - x = (T *)kmem_alloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) + x = kmem_zalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) - x = (T)kmem_alloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) + x = (T)kmem_zalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) - x = devm_kmalloc(E2,E1,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) + x = devm_kzalloc(E2,E1,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) - x = (T *)devm_kmalloc(E2,E1,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) + x = devm_kzalloc(E2,E1,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) - x = (T)devm_kmalloc(E2,E1,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) + x = (T)devm_kzalloc(E2,E1,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) - x = kvmalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) + x = kvzalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) - x = (T *)kvmalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) + x = kvzalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) - x = (T)kvmalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) + x = (T)kvzalloc(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) - x = kvmalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) + x = kvzalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) - x = (T *)kvmalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) + x = kvzalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) - x = (T)kvmalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) + x = (T)kvzalloc_node(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)   if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) - memset((T2)x,0,E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) @depends on patch@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) expression E1,E2,E3,E4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)   x = (T)dma_alloc_coherent(E1, E2, E3, E4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)   if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) - memset((T2)x, 0, E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) //----------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) //  For org mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) //----------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) @r depends on org || report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) expression E1,E2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) position p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  x = (T)kmalloc@p(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  memset((T2)x,0,E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) p << r.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) x << r.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) msg="%s" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) msg_safe=msg.replace("[","@(").replace("]",")")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) coccilib.org.print_todo(p[0], msg_safe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) p << r.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) x << r.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) msg="WARNING: kzalloc should be used for %s, instead of kmalloc/memset" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) coccilib.report.print_report(p[0], msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) //-----------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) @r1 depends on org || report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) expression E1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) position p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  x = (T)vmalloc@p(E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  memset((T2)x,0,E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) p << r1.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) x << r1.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) msg="%s" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) msg_safe=msg.replace("[","@(").replace("]",")")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) coccilib.org.print_todo(p[0], msg_safe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) p << r1.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) x << r1.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) msg="WARNING: vzalloc should be used for %s, instead of vmalloc/memset" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) coccilib.report.print_report(p[0], msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) //-----------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) @r2 depends on org || report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) expression E1,E2,E3,E4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) position p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  x = (T)dma_alloc_coherent@p(E1,E2,E3,E4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  memset((T2)x,0,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) p << r2.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) x << r2.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) msg="%s" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) msg_safe=msg.replace("[","@(").replace("]",")")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) coccilib.org.print_todo(p[0], msg_safe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) p << r2.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) x << r2.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) msg="WARNING: dma_alloc_coherent used in %s already zeroes out memory, so memset is not needed" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) coccilib.report.print_report(p[0], msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) //-----------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) @r3 depends on org || report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) expression E1,E2,E3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) position p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  x = (T)kmalloc_node@p(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  memset((T2)x,0,E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) p << r3.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) x << r3.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) msg="%s" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) msg_safe=msg.replace("[","@(").replace("]",")")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) coccilib.org.print_todo(p[0], msg_safe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) p << r3.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) x << r3.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) msg="WARNING: kzalloc_node should be used for %s, instead of kmalloc_node/memset" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) coccilib.report.print_report(p[0], msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) //-----------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) @r4 depends on org || report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) expression E1,E2,E3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) position p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  x = (T)kmem_cache_alloc@p(E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)  memset((T2)x,0,E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) p << r4.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) x << r4.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) msg="%s" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) msg_safe=msg.replace("[","@(").replace("]",")")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) coccilib.org.print_todo(p[0], msg_safe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) p << r4.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) x << r4.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) msg="WARNING: kmem_cache_zalloc should be used for %s, instead of kmem_cache_alloc/memset" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) coccilib.report.print_report(p[0], msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) //-----------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) @r5 depends on org || report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) expression E1,E2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) position p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)  x = (T)kmem_alloc@p(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)  if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)  memset((T2)x,0,E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) p << r5.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) x << r5.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) msg="%s" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) msg_safe=msg.replace("[","@(").replace("]",")")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) coccilib.org.print_todo(p[0], msg_safe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) p << r5.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) x << r5.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) msg="WARNING: kmem_zalloc should be used for %s, instead of kmem_alloc/memset" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) coccilib.report.print_report(p[0], msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) //-----------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) @r6 depends on org || report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) expression E1,E2,E3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) position p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)  x = (T)devm_kmalloc@p(E2,E1,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)  if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)  memset((T2)x,0,E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) p << r6.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) x << r6.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) msg="%s" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) msg_safe=msg.replace("[","@(").replace("]",")")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) coccilib.org.print_todo(p[0], msg_safe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) p << r6.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) x << r6.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) msg="WARNING: devm_kzalloc should be used for %s, instead of devm_kmalloc/memset" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) coccilib.report.print_report(p[0], msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) //-----------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) @r7 depends on org || report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) expression E1,E2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) position p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  x = (T)kvmalloc@p(E1,E2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)  if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)  memset((T2)x,0,E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) p << r7.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) x << r7.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) msg="%s" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) msg_safe=msg.replace("[","@(").replace("]",")")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) coccilib.org.print_todo(p[0], msg_safe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) p << r7.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) x << r7.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) msg="WARNING: kvzalloc should be used for %s, instead of kvmalloc/memset" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) coccilib.report.print_report(p[0], msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) //-----------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) @r9 depends on org || report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) type T, T2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) expression x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) expression E1,E2,E3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) statement S;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) position p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)  x = (T)kvmalloc_node@p(E1,E2,E3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)  if ((x==NULL) || ...) S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)  memset((T2)x,0,E1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) p << r9.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) x << r9.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) msg="%s" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) msg_safe=msg.replace("[","@(").replace("]",")")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) coccilib.org.print_todo(p[0], msg_safe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) p << r9.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) x << r9.x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) msg="WARNING: kvzalloc_node should be used for %s, instead of kvmalloc_node/memset" % (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) coccilib.report.print_report(p[0], msg)