summaryrefslogtreecommitdiff
path: root/drivers/bus
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 /drivers/bus
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 'drivers/bus')
-rw-r--r--drivers/bus/dpaa/base/fman/of.c7
-rw-r--r--drivers/bus/pci/linux/pci_uio.c3
2 files changed, 6 insertions, 4 deletions
diff --git a/drivers/bus/dpaa/base/fman/of.c b/drivers/bus/dpaa/base/fman/of.c
index a7f3174..1e97be5 100644
--- a/drivers/bus/dpaa/base/fman/of.c
+++ b/drivers/bus/dpaa/base/fman/of.c
@@ -6,6 +6,7 @@
*/
#include <of.h>
+#include <rte_string_fns.h>
#include <rte_dpaa_logs.h>
static int alive;
@@ -60,7 +61,7 @@ process_file(struct dirent *dent, struct dt_dir *parent)
return;
}
f->node.is_file = 1;
- snprintf(f->node.node.name, NAME_MAX, "%s", dent->d_name);
+ strlcpy(f->node.node.name, dent->d_name, NAME_MAX);
snprintf(f->node.node.full_name, PATH_MAX, "%s/%s",
parent->node.node.full_name, dent->d_name);
f->parent = parent;
@@ -117,8 +118,8 @@ iterate_dir(struct dirent **d, int num, struct dt_dir *dt)
perror("malloc");
return -ENOMEM;
}
- snprintf(subdir->node.node.name, NAME_MAX, "%s",
- d[loop]->d_name);
+ strlcpy(subdir->node.node.name, d[loop]->d_name,
+ NAME_MAX);
snprintf(subdir->node.node.full_name, PATH_MAX,
"%s/%s", dt->node.node.full_name,
d[loop]->d_name);
diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index 09ecbb7..65f4896 100644
--- a/drivers/bus/pci/linux/pci_uio.c
+++ b/drivers/bus/pci/linux/pci_uio.c
@@ -16,6 +16,7 @@
#include <sys/io.h>
#endif
+#include <rte_string_fns.h>
#include <rte_log.h>
#include <rte_pci.h>
#include <rte_bus_pci.h>
@@ -268,7 +269,7 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
goto error;
}
- snprintf((*uio_res)->path, sizeof((*uio_res)->path), "%s", devname);
+ strlcpy((*uio_res)->path, devname, sizeof((*uio_res)->path));
memcpy(&(*uio_res)->pci_addr, &dev->addr, sizeof((*uio_res)->pci_addr));
return 0;