1 // SPDX-License-Identifier: GPL-2.0-only
2 /// Use kmemdup rather than duplicating its implementation
5 // Copyright: (C) 2010-2012 Nicolas Palix.
6 // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
7 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
8 // URL: http://coccinelle.lip6.fr/
10 // Options: --no-includes --include-headers
23 to = \(kmalloc@p\|kzalloc@p\)(strlen(from) + 1,flag);
32 ... when != \( x = E1 \| from = E1 \)
33 to = \(kmalloc@p\|kzalloc@p\)(x,flag);
36 expression from,to,size,flag;
37 position p != {r1.p,r2.p};
41 - to = \(kmalloc@p\|kzalloc@p\)(size,flag);
42 + to = kmemdup(from,size,flag);
43 if (to==NULL || ...) S
44 - memcpy(to, from, size);
47 expression from,to,size,flag;
48 position p != {r1.p,r2.p};
52 * to = \(kmalloc@p\|kzalloc@p\)(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 kmemdup")
62 @script:python depends on report@
66 coccilib.report.print_report(p[0], "WARNING opportunity for kmemdup")