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 if (to==NULL || ...) S
53 * memcpy(to, from, size);
55 @script:python depends on org@
59 coccilib.org.print_todo(p[0], "WARNING opportunity for kmemdup")
61 @script:python depends on report@
65 coccilib.report.print_report(p[0], "WARNING opportunity for kmemdup")