1 /// Use kmemdup rather than duplicating its implementation
4 // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2.
5 // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2.
6 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
7 // URL: http://coccinelle.lip6.fr/
9 // Options: -no_includes -include_headers
22 to = \(kmalloc@p\|kzalloc@p\)(strlen(from) + 1,flag);
31 ... when != \( x = E1 \| from = E1 \)
32 to = \(kmalloc@p\|kzalloc@p\)(x,flag);
35 expression from,to,size,flag;
36 position p != {r1.p,r2.p};
40 - to = \(kmalloc@p\|kzalloc@p\)(size,flag);
41 + to = kmemdup(from,size,flag);
42 if (to==NULL || ...) S
43 - memcpy(to, from, size);
46 expression from,to,size,flag;
47 position p != {r1.p,r2.p};
51 * to = \(kmalloc@p\|kzalloc@p\)(size,flag);
52 to = kmemdup(from,size,flag);
53 if (to==NULL || ...) S
54 * memcpy(to, from, size);
56 @script:python depends on org@
60 coccilib.org.print_todo(p[0], "WARNING opportunity for kmemdep")
62 @script:python depends on report@
66 coccilib.report.print_report(p[0], "WARNING opportunity for kmemdep")