numam-dpdk/devtools/cocci/strlcpy.cocci
Bruce Richardson a5df16c1f7 devtools/cocci: make strlcpy replacement smarter
The original coccinelle script worked by replacing instances of
snprintf(.."%s",...) with strlcpy(), but only where the source and dest
parameters were plain identifiers. Allowing expressions for those params
opens up a wide range of other possible changes.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2019-04-04 22:44:02 +02:00

8 lines
107 B
Plaintext

@use_strlcpy@
expression src, dst, size;
@@
(
- snprintf(dst, size, "%s", src)
+ strlcpy(dst, src, size)
)