summaryrefslogtreecommitdiff
path: root/lib/librte_reorder
diff options
context:
space:
mode:
authorBruce Richardson <bruce.richardson@intel.com>2019-04-03 15:45:05 +0100
committerThomas Monjalon <thomas@monjalon.net>2019-04-04 22:46:05 +0200
commit6723c0fc7207ca4416822b170b1485a78aa47c7c (patch)
treefef3c6683019dcdf1403761e047308af49f49f8f /lib/librte_reorder
parentf9acaf84e923066344bd3467e4703da66f1f23a8 (diff)
downloaddpdk-6723c0fc7207ca4416822b170b1485a78aa47c7c.zip
dpdk-6723c0fc7207ca4416822b170b1485a78aa47c7c.tar.gz
dpdk-6723c0fc7207ca4416822b170b1485a78aa47c7c.tar.xz
replace snprintf with strlcpy
Do a global replace of snprintf(..."%s",...) with strlcpy, adding in the rte_string_fns.h header if needed. The function changes in this patch were auto-generated via command: spatch --sp-file devtools/cocci/strlcpy.cocci --dir . --in-place and then the files edited using awk to add in the missing header: gawk -i inplace '/include <rte_/ && ! seen { \ print "#include <rte_string_fns.h>"; seen=1} {print}' Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Diffstat (limited to 'lib/librte_reorder')
-rw-r--r--lib/librte_reorder/rte_reorder.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index ecf539d..b15328b 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -5,6 +5,7 @@
#include <inttypes.h>
#include <string.h>
+#include <rte_string_fns.h>
#include <rte_log.h>
#include <rte_mbuf.h>
#include <rte_eal_memconfig.h>
@@ -82,7 +83,7 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize,
}
memset(b, 0, bufsize);
- snprintf(b->name, sizeof(b->name), "%s", name);
+ strlcpy(b->name, name, sizeof(b->name));
b->memsize = bufsize;
b->order_buf.size = b->ready_buf.size = size;
b->order_buf.mask = b->ready_buf.mask = size - 1;
@@ -161,7 +162,7 @@ rte_reorder_reset(struct rte_reorder_buffer *b)
char name[RTE_REORDER_NAMESIZE];
rte_reorder_free_mbufs(b);
- snprintf(name, sizeof(name), "%s", b->name);
+ strlcpy(name, b->name, sizeof(name));
/* No error checking as current values should be valid */
rte_reorder_init(b, b->memsize, name, b->order_buf.size);
}