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