xref: /openbmc/linux/scripts/coccinelle/api/alloc/zalloc-simple.cocci (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
17f904d7eSThomas Gleixner// SPDX-License-Identifier: GPL-2.0-only
21936f8f3SHimanshu Jha///
31936f8f3SHimanshu Jha/// Use zeroing allocator rather than allocator followed by memset with 0
41936f8f3SHimanshu Jha///
51936f8f3SHimanshu Jha/// This considers some simple cases that are common and easy to validate
61936f8f3SHimanshu Jha/// Note in particular that there are no ...s in the rule, so all of the
71936f8f3SHimanshu Jha/// matched code has to be contiguous
81936f8f3SHimanshu Jha///
91936f8f3SHimanshu Jha// Confidence: High
107f904d7eSThomas Gleixner// Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU.
117f904d7eSThomas Gleixner// Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6.
127f904d7eSThomas Gleixner// Copyright: (C) 2017 Himanshu Jha
13*f01701ceSJulia Lawall// URL: https://coccinelle.gitlabpages.inria.fr/website
141936f8f3SHimanshu Jha// Options: --no-includes --include-headers
151936f8f3SHimanshu Jha//
161936f8f3SHimanshu Jha// Keywords: kmalloc, kzalloc
171936f8f3SHimanshu Jha// Version min: < 2.6.12 kmalloc
181936f8f3SHimanshu Jha// Version min:   2.6.14 kzalloc
191936f8f3SHimanshu Jha//
201936f8f3SHimanshu Jha
211936f8f3SHimanshu Jhavirtual context
221936f8f3SHimanshu Jhavirtual patch
231936f8f3SHimanshu Jhavirtual org
241936f8f3SHimanshu Jhavirtual report
251936f8f3SHimanshu Jha
261936f8f3SHimanshu Jha//----------------------------------------------------------
271936f8f3SHimanshu Jha//  For context mode
281936f8f3SHimanshu Jha//----------------------------------------------------------
291936f8f3SHimanshu Jha
301936f8f3SHimanshu Jha@depends on context@
311936f8f3SHimanshu Jhatype T, T2;
321936f8f3SHimanshu Jhaexpression x;
331936f8f3SHimanshu Jhaexpression E1;
341936f8f3SHimanshu Jhastatement S;
351936f8f3SHimanshu Jha@@
361936f8f3SHimanshu Jha
371936f8f3SHimanshu Jha* x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
381936f8f3SHimanshu Jha  kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
396fbd8569Szhong jiang  devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|kvmalloc_node(E1,...)\);
401936f8f3SHimanshu Jha  if ((x==NULL) || ...) S
411936f8f3SHimanshu Jha* memset((T2)x,0,E1);
421936f8f3SHimanshu Jha
431936f8f3SHimanshu Jha//----------------------------------------------------------
441936f8f3SHimanshu Jha//  For patch mode
451936f8f3SHimanshu Jha//----------------------------------------------------------
461936f8f3SHimanshu Jha
471936f8f3SHimanshu Jha@depends on patch@
481936f8f3SHimanshu Jhatype T, T2;
491936f8f3SHimanshu Jhaexpression x;
501936f8f3SHimanshu Jhaexpression E1,E2,E3,E4;
511936f8f3SHimanshu Jhastatement S;
521936f8f3SHimanshu Jha@@
531936f8f3SHimanshu Jha
541936f8f3SHimanshu Jha(
551936f8f3SHimanshu Jha- x = kmalloc(E1,E2);
561936f8f3SHimanshu Jha+ x = kzalloc(E1,E2);
571936f8f3SHimanshu Jha|
581936f8f3SHimanshu Jha- x = (T *)kmalloc(E1,E2);
591936f8f3SHimanshu Jha+ x = kzalloc(E1,E2);
601936f8f3SHimanshu Jha|
611936f8f3SHimanshu Jha- x = (T)kmalloc(E1,E2);
621936f8f3SHimanshu Jha+ x = (T)kzalloc(E1,E2);
631936f8f3SHimanshu Jha|
641936f8f3SHimanshu Jha- x = vmalloc(E1);
651936f8f3SHimanshu Jha+ x = vzalloc(E1);
661936f8f3SHimanshu Jha|
671936f8f3SHimanshu Jha- x = (T *)vmalloc(E1);
681936f8f3SHimanshu Jha+ x = vzalloc(E1);
691936f8f3SHimanshu Jha|
701936f8f3SHimanshu Jha- x = (T)vmalloc(E1);
711936f8f3SHimanshu Jha+ x = (T)vzalloc(E1);
721936f8f3SHimanshu Jha|
731936f8f3SHimanshu Jha- x = kmalloc_node(E1,E2,E3);
741936f8f3SHimanshu Jha+ x = kzalloc_node(E1,E2,E3);
751936f8f3SHimanshu Jha|
761936f8f3SHimanshu Jha- x = (T *)kmalloc_node(E1,E2,E3);
771936f8f3SHimanshu Jha+ x = kzalloc_node(E1,E2,E3);
781936f8f3SHimanshu Jha|
791936f8f3SHimanshu Jha- x = (T)kmalloc_node(E1,E2,E3);
801936f8f3SHimanshu Jha+ x = (T)kzalloc_node(E1,E2,E3);
811936f8f3SHimanshu Jha|
821936f8f3SHimanshu Jha- x = kmem_cache_alloc(E3,E4);
831936f8f3SHimanshu Jha+ x = kmem_cache_zalloc(E3,E4);
841936f8f3SHimanshu Jha|
851936f8f3SHimanshu Jha- x = (T *)kmem_cache_alloc(E3,E4);
861936f8f3SHimanshu Jha+ x = kmem_cache_zalloc(E3,E4);
871936f8f3SHimanshu Jha|
881936f8f3SHimanshu Jha- x = (T)kmem_cache_alloc(E3,E4);
891936f8f3SHimanshu Jha+ x = (T)kmem_cache_zalloc(E3,E4);
901936f8f3SHimanshu Jha|
911936f8f3SHimanshu Jha- x = kmem_alloc(E1,E2);
921936f8f3SHimanshu Jha+ x = kmem_zalloc(E1,E2);
931936f8f3SHimanshu Jha|
941936f8f3SHimanshu Jha- x = (T *)kmem_alloc(E1,E2);
951936f8f3SHimanshu Jha+ x = kmem_zalloc(E1,E2);
961936f8f3SHimanshu Jha|
971936f8f3SHimanshu Jha- x = (T)kmem_alloc(E1,E2);
981936f8f3SHimanshu Jha+ x = (T)kmem_zalloc(E1,E2);
991936f8f3SHimanshu Jha|
1001936f8f3SHimanshu Jha- x = devm_kmalloc(E2,E1,E3);
1011936f8f3SHimanshu Jha+ x = devm_kzalloc(E2,E1,E3);
1021936f8f3SHimanshu Jha|
1031936f8f3SHimanshu Jha- x = (T *)devm_kmalloc(E2,E1,E3);
1041936f8f3SHimanshu Jha+ x = devm_kzalloc(E2,E1,E3);
1051936f8f3SHimanshu Jha|
1061936f8f3SHimanshu Jha- x = (T)devm_kmalloc(E2,E1,E3);
1071936f8f3SHimanshu Jha+ x = (T)devm_kzalloc(E2,E1,E3);
1081936f8f3SHimanshu Jha|
1091936f8f3SHimanshu Jha- x = kvmalloc(E1,E2);
1101936f8f3SHimanshu Jha+ x = kvzalloc(E1,E2);
1111936f8f3SHimanshu Jha|
1121936f8f3SHimanshu Jha- x = (T *)kvmalloc(E1,E2);
1131936f8f3SHimanshu Jha+ x = kvzalloc(E1,E2);
1141936f8f3SHimanshu Jha|
1151936f8f3SHimanshu Jha- x = (T)kvmalloc(E1,E2);
1161936f8f3SHimanshu Jha+ x = (T)kvzalloc(E1,E2);
1171936f8f3SHimanshu Jha|
1181936f8f3SHimanshu Jha- x = kvmalloc_node(E1,E2,E3);
1191936f8f3SHimanshu Jha+ x = kvzalloc_node(E1,E2,E3);
1201936f8f3SHimanshu Jha|
1211936f8f3SHimanshu Jha- x = (T *)kvmalloc_node(E1,E2,E3);
1221936f8f3SHimanshu Jha+ x = kvzalloc_node(E1,E2,E3);
1231936f8f3SHimanshu Jha|
1241936f8f3SHimanshu Jha- x = (T)kvmalloc_node(E1,E2,E3);
1251936f8f3SHimanshu Jha+ x = (T)kvzalloc_node(E1,E2,E3);
1261936f8f3SHimanshu Jha)
1271936f8f3SHimanshu Jha  if ((x==NULL) || ...) S
1281936f8f3SHimanshu Jha- memset((T2)x,0,E1);
1291936f8f3SHimanshu Jha
1307a2624e6SAlex Dewar@depends on patch@
1317a2624e6SAlex Dewartype T, T2;
1327a2624e6SAlex Dewarexpression x;
1337a2624e6SAlex Dewarexpression E1,E2,E3,E4;
1347a2624e6SAlex Dewarstatement S;
1357a2624e6SAlex Dewar@@
1367a2624e6SAlex Dewar  x = (T)dma_alloc_coherent(E1, E2, E3, E4);
1377a2624e6SAlex Dewar  if ((x==NULL) || ...) S
1387a2624e6SAlex Dewar- memset((T2)x, 0, E2);
1397a2624e6SAlex Dewar
1401936f8f3SHimanshu Jha//----------------------------------------------------------
1411936f8f3SHimanshu Jha//  For org mode
1421936f8f3SHimanshu Jha//----------------------------------------------------------
1431936f8f3SHimanshu Jha
1441936f8f3SHimanshu Jha@r depends on org || report@
1451936f8f3SHimanshu Jhatype T, T2;
1461936f8f3SHimanshu Jhaexpression x;
1471936f8f3SHimanshu Jhaexpression E1,E2;
1481936f8f3SHimanshu Jhastatement S;
1491936f8f3SHimanshu Jhaposition p;
1501936f8f3SHimanshu Jha@@
1511936f8f3SHimanshu Jha
1521936f8f3SHimanshu Jha x = (T)kmalloc@p(E1,E2);
1531936f8f3SHimanshu Jha if ((x==NULL) || ...) S
1541936f8f3SHimanshu Jha memset((T2)x,0,E1);
1551936f8f3SHimanshu Jha
1561936f8f3SHimanshu Jha@script:python depends on org@
1571936f8f3SHimanshu Jhap << r.p;
1581936f8f3SHimanshu Jhax << r.x;
1591936f8f3SHimanshu Jha@@
1601936f8f3SHimanshu Jha
1611936f8f3SHimanshu Jhamsg="%s" % (x)
1621936f8f3SHimanshu Jhamsg_safe=msg.replace("[","@(").replace("]",")")
1631936f8f3SHimanshu Jhacoccilib.org.print_todo(p[0], msg_safe)
1641936f8f3SHimanshu Jha
1651936f8f3SHimanshu Jha@script:python depends on report@
1661936f8f3SHimanshu Jhap << r.p;
1671936f8f3SHimanshu Jhax << r.x;
1681936f8f3SHimanshu Jha@@
1691936f8f3SHimanshu Jha
1701936f8f3SHimanshu Jhamsg="WARNING: kzalloc should be used for %s, instead of kmalloc/memset" % (x)
1711936f8f3SHimanshu Jhacoccilib.report.print_report(p[0], msg)
1721936f8f3SHimanshu Jha
1731936f8f3SHimanshu Jha//-----------------------------------------------------------------
1741936f8f3SHimanshu Jha@r1 depends on org || report@
1751936f8f3SHimanshu Jhatype T, T2;
1761936f8f3SHimanshu Jhaexpression x;
1771936f8f3SHimanshu Jhaexpression E1;
1781936f8f3SHimanshu Jhastatement S;
1791936f8f3SHimanshu Jhaposition p;
1801936f8f3SHimanshu Jha@@
1811936f8f3SHimanshu Jha
1821936f8f3SHimanshu Jha x = (T)vmalloc@p(E1);
1831936f8f3SHimanshu Jha if ((x==NULL) || ...) S
1841936f8f3SHimanshu Jha memset((T2)x,0,E1);
1851936f8f3SHimanshu Jha
1861936f8f3SHimanshu Jha@script:python depends on org@
1871936f8f3SHimanshu Jhap << r1.p;
1881936f8f3SHimanshu Jhax << r1.x;
1891936f8f3SHimanshu Jha@@
1901936f8f3SHimanshu Jha
1911936f8f3SHimanshu Jhamsg="%s" % (x)
1921936f8f3SHimanshu Jhamsg_safe=msg.replace("[","@(").replace("]",")")
1931936f8f3SHimanshu Jhacoccilib.org.print_todo(p[0], msg_safe)
1941936f8f3SHimanshu Jha
1951936f8f3SHimanshu Jha@script:python depends on report@
1961936f8f3SHimanshu Jhap << r1.p;
1971936f8f3SHimanshu Jhax << r1.x;
1981936f8f3SHimanshu Jha@@
1991936f8f3SHimanshu Jha
2001936f8f3SHimanshu Jhamsg="WARNING: vzalloc should be used for %s, instead of vmalloc/memset" % (x)
2011936f8f3SHimanshu Jhacoccilib.report.print_report(p[0], msg)
2021936f8f3SHimanshu Jha
2031936f8f3SHimanshu Jha//-----------------------------------------------------------------
2041936f8f3SHimanshu Jha@r2 depends on org || report@
2051936f8f3SHimanshu Jhatype T, T2;
2061936f8f3SHimanshu Jhaexpression x;
2071936f8f3SHimanshu Jhaexpression E1,E2,E3,E4;
2081936f8f3SHimanshu Jhastatement S;
2091936f8f3SHimanshu Jhaposition p;
2101936f8f3SHimanshu Jha@@
2111936f8f3SHimanshu Jha
2127a2624e6SAlex Dewar x = (T)dma_alloc_coherent@p(E1,E2,E3,E4);
2131936f8f3SHimanshu Jha if ((x==NULL) || ...) S
2147a2624e6SAlex Dewar memset((T2)x,0,E2);
2151936f8f3SHimanshu Jha
2161936f8f3SHimanshu Jha@script:python depends on org@
2171936f8f3SHimanshu Jhap << r2.p;
2181936f8f3SHimanshu Jhax << r2.x;
2191936f8f3SHimanshu Jha@@
2201936f8f3SHimanshu Jha
2211936f8f3SHimanshu Jhamsg="%s" % (x)
2221936f8f3SHimanshu Jhamsg_safe=msg.replace("[","@(").replace("]",")")
2231936f8f3SHimanshu Jhacoccilib.org.print_todo(p[0], msg_safe)
2241936f8f3SHimanshu Jha
2251936f8f3SHimanshu Jha@script:python depends on report@
2261936f8f3SHimanshu Jhap << r2.p;
2271936f8f3SHimanshu Jhax << r2.x;
2281936f8f3SHimanshu Jha@@
2291936f8f3SHimanshu Jha
2307a2624e6SAlex Dewarmsg="WARNING: dma_alloc_coherent used in %s already zeroes out memory, so memset is not needed" % (x)
2311936f8f3SHimanshu Jhacoccilib.report.print_report(p[0], msg)
2321936f8f3SHimanshu Jha
2331936f8f3SHimanshu Jha//-----------------------------------------------------------------
2341936f8f3SHimanshu Jha@r3 depends on org || report@
2351936f8f3SHimanshu Jhatype T, T2;
2361936f8f3SHimanshu Jhaexpression x;
2371936f8f3SHimanshu Jhaexpression E1,E2,E3;
2381936f8f3SHimanshu Jhastatement S;
2391936f8f3SHimanshu Jhaposition p;
2401936f8f3SHimanshu Jha@@
2411936f8f3SHimanshu Jha
2421936f8f3SHimanshu Jha x = (T)kmalloc_node@p(E1,E2,E3);
2431936f8f3SHimanshu Jha if ((x==NULL) || ...) S
2441936f8f3SHimanshu Jha memset((T2)x,0,E1);
2451936f8f3SHimanshu Jha
2461936f8f3SHimanshu Jha@script:python depends on org@
2471936f8f3SHimanshu Jhap << r3.p;
2481936f8f3SHimanshu Jhax << r3.x;
2491936f8f3SHimanshu Jha@@
2501936f8f3SHimanshu Jha
2511936f8f3SHimanshu Jhamsg="%s" % (x)
2521936f8f3SHimanshu Jhamsg_safe=msg.replace("[","@(").replace("]",")")
2531936f8f3SHimanshu Jhacoccilib.org.print_todo(p[0], msg_safe)
2541936f8f3SHimanshu Jha
2551936f8f3SHimanshu Jha@script:python depends on report@
2561936f8f3SHimanshu Jhap << r3.p;
2571936f8f3SHimanshu Jhax << r3.x;
2581936f8f3SHimanshu Jha@@
2591936f8f3SHimanshu Jha
2601936f8f3SHimanshu Jhamsg="WARNING: kzalloc_node should be used for %s, instead of kmalloc_node/memset" % (x)
2611936f8f3SHimanshu Jhacoccilib.report.print_report(p[0], msg)
2621936f8f3SHimanshu Jha
2631936f8f3SHimanshu Jha//-----------------------------------------------------------------
2641936f8f3SHimanshu Jha@r4 depends on org || report@
2651936f8f3SHimanshu Jhatype T, T2;
2661936f8f3SHimanshu Jhaexpression x;
2671936f8f3SHimanshu Jhaexpression E1,E2,E3;
2681936f8f3SHimanshu Jhastatement S;
2691936f8f3SHimanshu Jhaposition p;
2701936f8f3SHimanshu Jha@@
2711936f8f3SHimanshu Jha
2721936f8f3SHimanshu Jha x = (T)kmem_cache_alloc@p(E2,E3);
2731936f8f3SHimanshu Jha if ((x==NULL) || ...) S
2741936f8f3SHimanshu Jha memset((T2)x,0,E1);
2751936f8f3SHimanshu Jha
2761936f8f3SHimanshu Jha@script:python depends on org@
2771936f8f3SHimanshu Jhap << r4.p;
2781936f8f3SHimanshu Jhax << r4.x;
2791936f8f3SHimanshu Jha@@
2801936f8f3SHimanshu Jha
2811936f8f3SHimanshu Jhamsg="%s" % (x)
2821936f8f3SHimanshu Jhamsg_safe=msg.replace("[","@(").replace("]",")")
2831936f8f3SHimanshu Jhacoccilib.org.print_todo(p[0], msg_safe)
2841936f8f3SHimanshu Jha
2851936f8f3SHimanshu Jha@script:python depends on report@
2861936f8f3SHimanshu Jhap << r4.p;
2871936f8f3SHimanshu Jhax << r4.x;
2881936f8f3SHimanshu Jha@@
2891936f8f3SHimanshu Jha
2901936f8f3SHimanshu Jhamsg="WARNING: kmem_cache_zalloc should be used for %s, instead of kmem_cache_alloc/memset" % (x)
2911936f8f3SHimanshu Jhacoccilib.report.print_report(p[0], msg)
2921936f8f3SHimanshu Jha
2931936f8f3SHimanshu Jha//-----------------------------------------------------------------
2941936f8f3SHimanshu Jha@r5 depends on org || report@
2951936f8f3SHimanshu Jhatype T, T2;
2961936f8f3SHimanshu Jhaexpression x;
2971936f8f3SHimanshu Jhaexpression E1,E2;
2981936f8f3SHimanshu Jhastatement S;
2991936f8f3SHimanshu Jhaposition p;
3001936f8f3SHimanshu Jha@@
3011936f8f3SHimanshu Jha
3021936f8f3SHimanshu Jha x = (T)kmem_alloc@p(E1,E2);
3031936f8f3SHimanshu Jha if ((x==NULL) || ...) S
3041936f8f3SHimanshu Jha memset((T2)x,0,E1);
3051936f8f3SHimanshu Jha
3061936f8f3SHimanshu Jha@script:python depends on org@
3071936f8f3SHimanshu Jhap << r5.p;
3081936f8f3SHimanshu Jhax << r5.x;
3091936f8f3SHimanshu Jha@@
3101936f8f3SHimanshu Jha
3111936f8f3SHimanshu Jhamsg="%s" % (x)
3121936f8f3SHimanshu Jhamsg_safe=msg.replace("[","@(").replace("]",")")
3131936f8f3SHimanshu Jhacoccilib.org.print_todo(p[0], msg_safe)
3141936f8f3SHimanshu Jha
3151936f8f3SHimanshu Jha@script:python depends on report@
3161936f8f3SHimanshu Jhap << r5.p;
3171936f8f3SHimanshu Jhax << r5.x;
3181936f8f3SHimanshu Jha@@
3191936f8f3SHimanshu Jha
3201936f8f3SHimanshu Jhamsg="WARNING: kmem_zalloc should be used for %s, instead of kmem_alloc/memset" % (x)
3211936f8f3SHimanshu Jhacoccilib.report.print_report(p[0], msg)
3221936f8f3SHimanshu Jha
3231936f8f3SHimanshu Jha//-----------------------------------------------------------------
3241936f8f3SHimanshu Jha@r6 depends on org || report@
3251936f8f3SHimanshu Jhatype T, T2;
3261936f8f3SHimanshu Jhaexpression x;
3271936f8f3SHimanshu Jhaexpression E1,E2,E3;
3281936f8f3SHimanshu Jhastatement S;
3291936f8f3SHimanshu Jhaposition p;
3301936f8f3SHimanshu Jha@@
3311936f8f3SHimanshu Jha
3321936f8f3SHimanshu Jha x = (T)devm_kmalloc@p(E2,E1,E3);
3331936f8f3SHimanshu Jha if ((x==NULL) || ...) S
3341936f8f3SHimanshu Jha memset((T2)x,0,E1);
3351936f8f3SHimanshu Jha
3361936f8f3SHimanshu Jha@script:python depends on org@
3371936f8f3SHimanshu Jhap << r6.p;
3381936f8f3SHimanshu Jhax << r6.x;
3391936f8f3SHimanshu Jha@@
3401936f8f3SHimanshu Jha
3411936f8f3SHimanshu Jhamsg="%s" % (x)
3421936f8f3SHimanshu Jhamsg_safe=msg.replace("[","@(").replace("]",")")
3431936f8f3SHimanshu Jhacoccilib.org.print_todo(p[0], msg_safe)
3441936f8f3SHimanshu Jha
3451936f8f3SHimanshu Jha@script:python depends on report@
3461936f8f3SHimanshu Jhap << r6.p;
3471936f8f3SHimanshu Jhax << r6.x;
3481936f8f3SHimanshu Jha@@
3491936f8f3SHimanshu Jha
3501936f8f3SHimanshu Jhamsg="WARNING: devm_kzalloc should be used for %s, instead of devm_kmalloc/memset" % (x)
3511936f8f3SHimanshu Jhacoccilib.report.print_report(p[0], msg)
3521936f8f3SHimanshu Jha
3531936f8f3SHimanshu Jha//-----------------------------------------------------------------
3541936f8f3SHimanshu Jha@r7 depends on org || report@
3551936f8f3SHimanshu Jhatype T, T2;
3561936f8f3SHimanshu Jhaexpression x;
3571936f8f3SHimanshu Jhaexpression E1,E2;
3581936f8f3SHimanshu Jhastatement S;
3591936f8f3SHimanshu Jhaposition p;
3601936f8f3SHimanshu Jha@@
3611936f8f3SHimanshu Jha
3621936f8f3SHimanshu Jha x = (T)kvmalloc@p(E1,E2);
3631936f8f3SHimanshu Jha if ((x==NULL) || ...) S
3641936f8f3SHimanshu Jha memset((T2)x,0,E1);
3651936f8f3SHimanshu Jha
3661936f8f3SHimanshu Jha@script:python depends on org@
3671936f8f3SHimanshu Jhap << r7.p;
3681936f8f3SHimanshu Jhax << r7.x;
3691936f8f3SHimanshu Jha@@
3701936f8f3SHimanshu Jha
3711936f8f3SHimanshu Jhamsg="%s" % (x)
3721936f8f3SHimanshu Jhamsg_safe=msg.replace("[","@(").replace("]",")")
3731936f8f3SHimanshu Jhacoccilib.org.print_todo(p[0], msg_safe)
3741936f8f3SHimanshu Jha
3751936f8f3SHimanshu Jha@script:python depends on report@
3761936f8f3SHimanshu Jhap << r7.p;
3771936f8f3SHimanshu Jhax << r7.x;
3781936f8f3SHimanshu Jha@@
3791936f8f3SHimanshu Jha
3801936f8f3SHimanshu Jhamsg="WARNING: kvzalloc should be used for %s, instead of kvmalloc/memset" % (x)
3811936f8f3SHimanshu Jhacoccilib.report.print_report(p[0], msg)
3821936f8f3SHimanshu Jha
3831936f8f3SHimanshu Jha//-----------------------------------------------------------------
3841936f8f3SHimanshu Jha@r9 depends on org || report@
3851936f8f3SHimanshu Jhatype T, T2;
3861936f8f3SHimanshu Jhaexpression x;
3871936f8f3SHimanshu Jhaexpression E1,E2,E3;
3881936f8f3SHimanshu Jhastatement S;
3891936f8f3SHimanshu Jhaposition p;
3901936f8f3SHimanshu Jha@@
3911936f8f3SHimanshu Jha
3921936f8f3SHimanshu Jha x = (T)kvmalloc_node@p(E1,E2,E3);
3931936f8f3SHimanshu Jha if ((x==NULL) || ...) S
3941936f8f3SHimanshu Jha memset((T2)x,0,E1);
3951936f8f3SHimanshu Jha
3961936f8f3SHimanshu Jha@script:python depends on org@
3971936f8f3SHimanshu Jhap << r9.p;
3981936f8f3SHimanshu Jhax << r9.x;
3991936f8f3SHimanshu Jha@@
4001936f8f3SHimanshu Jha
4011936f8f3SHimanshu Jhamsg="%s" % (x)
4021936f8f3SHimanshu Jhamsg_safe=msg.replace("[","@(").replace("]",")")
4031936f8f3SHimanshu Jhacoccilib.org.print_todo(p[0], msg_safe)
4041936f8f3SHimanshu Jha
4051936f8f3SHimanshu Jha@script:python depends on report@
4061936f8f3SHimanshu Jhap << r9.p;
4071936f8f3SHimanshu Jhax << r9.x;
4081936f8f3SHimanshu Jha@@
4091936f8f3SHimanshu Jha
4101936f8f3SHimanshu Jhamsg="WARNING: kvzalloc_node should be used for %s, instead of kvmalloc_node/memset" % (x)
4111936f8f3SHimanshu Jhacoccilib.report.print_report(p[0], msg)
412