summaryrefslogtreecommitdiff
path: root/drivers/bus
diff options
context:
space:
mode:
authorBruce Richardson <bruce.richardson@intel.com>2019-04-03 15:45:04 +0100
committerThomas Monjalon <thomas@monjalon.net>2019-04-04 22:45:54 +0200
commitf9acaf84e923066344bd3467e4703da66f1f23a8 (patch)
treecd3780dd1ae1739aee8930533401e58d67b3f32e /drivers/bus
parent277b6e7ef457729b88fe415dfd4a2184e5b329fb (diff)
downloaddpdk-f9acaf84e923066344bd3467e4703da66f1f23a8.zip
dpdk-f9acaf84e923066344bd3467e4703da66f1f23a8.tar.gz
dpdk-f9acaf84e923066344bd3467e4703da66f1f23a8.tar.xz
replace snprintf with strlcpy without adding extra include
For files that already have rte_string_fns.h included in them, we can do a straight replacement of snprintf(..."%s",...) with strlcpy. The changes in this patch were auto-generated via command: spatch --sp-file devtools/cocci/strlcpy-with-header.cocci --dir . --in-place Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Diffstat (limited to 'drivers/bus')
-rw-r--r--drivers/bus/pci/bsd/pci.c2
-rw-r--r--drivers/bus/vdev/vdev.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c
index d09f8ee..c7b90cb 100644
--- a/drivers/bus/pci/bsd/pci.c
+++ b/drivers/bus/pci/bsd/pci.c
@@ -145,7 +145,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;
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 87f0e2b..04f76a6 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -192,7 +192,7 @@ alloc_devargs(const char *name, const char *args)
else
devargs->args = strdup("");
- ret = snprintf(devargs->name, sizeof(devargs->name), "%s", name);
+ ret = strlcpy(devargs->name, name, sizeof(devargs->name));
if (ret < 0 || ret >= (int)sizeof(devargs->name)) {
free(devargs->args);
free(devargs);