devtools/cocci: create safer version of strlcpy script

The existing cocci script for coccinelle replaces all matching instances
of snprintf() with strlcpy() without regards to header inclusion. To allow
changes without build errors, we create a safer version of this script
that only makes changes when the rte_string_fns.h header is already
included.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
This commit is contained in:
Bruce Richardson 2019-04-03 15:45:03 +01:00 committed by Thomas Monjalon
parent a5df16c1f7
commit 277b6e7ef4

View file

@ -0,0 +1,12 @@
@include@
@@
#include <rte_string_fns.h>
@use_strlcpy depends on include@
expression src, dst, size;
@@
(
- snprintf(dst, size, "%s", src)
+ strlcpy(dst, src, size)
)