From: Bruce Richardson Date: Wed, 3 Apr 2019 14:45:03 +0000 (+0100) Subject: devtools/cocci: create safer version of strlcpy script X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=277b6e7ef457729b88fe415dfd4a2184e5b329fb;p=dpdk.git 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 --- diff --git a/devtools/cocci/strlcpy-with-header.cocci b/devtools/cocci/strlcpy-with-header.cocci new file mode 100644 index 0000000000..046cdbdad1 --- /dev/null +++ b/devtools/cocci/strlcpy-with-header.cocci @@ -0,0 +1,12 @@ +@include@ +@@ + +#include + +@use_strlcpy depends on include@ +expression src, dst, size; +@@ +( +- snprintf(dst, size, "%s", src) ++ strlcpy(dst, src, size) +)