summaryrefslogtreecommitdiff
path: root/examples/netmap_compat
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 /examples/netmap_compat
parent277b6e7ef457729b88fe415dfd4a2184e5b329fb (diff)
downloaddpdk-draft-windows-f9acaf84e923066344bd3467e4703da66f1f23a8.zip
dpdk-draft-windows-f9acaf84e923066344bd3467e4703da66f1f23a8.tar.gz
dpdk-draft-windows-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 'examples/netmap_compat')
-rw-r--r--examples/netmap_compat/bridge/bridge.c4
-rw-r--r--examples/netmap_compat/lib/compat_netmap.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/examples/netmap_compat/bridge/bridge.c b/examples/netmap_compat/bridge/bridge.c
index 216e010..d40e163 100644
--- a/examples/netmap_compat/bridge/bridge.c
+++ b/examples/netmap_compat/bridge/bridge.c
@@ -174,7 +174,7 @@ netmap_port_open(uint32_t idx)
port->fd = rte_netmap_open("/dev/netmap", O_RDWR);
- snprintf(req.nr_name, sizeof(req.nr_name), "%s", port->str);
+ strlcpy(req.nr_name, port->str, sizeof(req.nr_name));
req.nr_version = NETMAP_API;
req.nr_ringid = 0;
@@ -184,7 +184,7 @@ netmap_port_open(uint32_t idx)
return err;
}
- snprintf(req.nr_name, sizeof(req.nr_name), "%s", port->str);
+ strlcpy(req.nr_name, port->str, sizeof(req.nr_name));
req.nr_version = NETMAP_API;
req.nr_ringid = 0;
diff --git a/examples/netmap_compat/lib/compat_netmap.c b/examples/netmap_compat/lib/compat_netmap.c
index 0be0663..10a4379 100644
--- a/examples/netmap_compat/lib/compat_netmap.c
+++ b/examples/netmap_compat/lib/compat_netmap.c
@@ -302,7 +302,7 @@ netmap_regif(struct nmreq *req, uint32_t idx, uint16_t port)
if (req->nr_ringid != 0)
return -EINVAL;
- snprintf(nmif->ni_name, sizeof(nmif->ni_name), "%s", req->nr_name);
+ strlcpy(nmif->ni_name, req->nr_name, sizeof(nmif->ni_name));
nmif->ni_version = req->nr_version;
/* Netmap uses ni_(r|t)x_rings + 1 */