summaryrefslogtreecommitdiff
path: root/lib/librte_bbdev
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_bbdev
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_bbdev')
-rw-r--r--lib/librte_bbdev/rte_bbdev.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c
index c4cc18d..a3ab5d9 100644
--- a/lib/librte_bbdev/rte_bbdev.c
+++ b/lib/librte_bbdev/rte_bbdev.c
@@ -6,6 +6,7 @@
#include <string.h>
#include <stdbool.h>
+#include <rte_string_fns.h>
#include <rte_compat.h>
#include <rte_common.h>
#include <rte_errno.h>
@@ -214,7 +215,7 @@ rte_bbdev_allocate(const char *name)
bbdev->data->dev_id = dev_id;
bbdev->state = RTE_BBDEV_INITIALIZED;
- ret = snprintf(bbdev->data->name, RTE_BBDEV_NAME_MAX_LEN, "%s", name);
+ ret = strlcpy(bbdev->data->name, name, RTE_BBDEV_NAME_MAX_LEN);
if ((ret < 0) || (ret >= RTE_BBDEV_NAME_MAX_LEN)) {
rte_bbdev_log(ERR, "Copying device name \"%s\" failed", name);
return NULL;