From: Xiaolong Ye <xiaolong.ye@intel.com>
To: dev@dpdk.org, Maxime Coquelin <maxime.coquelin@redhat.com>,
Tiwei Bie <tiwei.bie@intel.com>,
Zhihong Wang <zhihong.wang@intel.com>
Cc: xiao.w.wang@intel.com, Rami Rosen <roszenrami@gmail.com>,
Wang Haiyue <haiyue.wang@intel.com>,
Xiaolong Ye <xiaolong.ye@intel.com>
Subject: [dpdk-dev] [PATCH] examples/vdpa: replace strncpy with strscpy function
Date: Thu, 4 Oct 2018 03:34:39 +0800 [thread overview]
Message-ID: <20181003193439.108373-1-xiaolong.ye@intel.com> (raw)
In-Reply-To: <32f53ad0-92f4-4415-7a05-eff0c6fa779d@redhat.com>
rte_strscpy is safer to use.
Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
---
examples/vdpa/main.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
index f96fa88b7..c5e8f58ec 100644
--- a/examples/vdpa/main.c
+++ b/examples/vdpa/main.c
@@ -13,6 +13,7 @@
#include <rte_vhost.h>
#include <rte_vdpa.h>
#include <rte_pci.h>
+#include <rte_string_fns.h>
#include <cmdline_parse.h>
#include <cmdline_socket.h>
@@ -73,7 +74,7 @@ parse_args(int argc, char **argv)
case 0:
if (strncmp(long_option[idx].name, "iface",
MAX_PATH_LEN) == 0) {
- strncpy(iface, optarg, MAX_PATH_LEN);
+ rte_strscpy(iface, optarg, MAX_PATH_LEN);
printf("iface %s\n", iface);
}
if (!strcmp(long_option[idx].name, "interactive")) {
@@ -325,7 +326,7 @@ static void cmd_create_vdpa_port_parsed(void *parsed_result,
struct cmd_create_result *res = parsed_result;
struct rte_vdpa_dev_addr addr;
- strncpy(vports[devcnt].ifname, res->socket_path, MAX_PATH_LEN);
+ rte_strscpy(vports[devcnt].ifname, res->socket_path, MAX_PATH_LEN);
if (rte_pci_addr_parse(res->bdf, &addr.pci_addr) != 0) {
cmdline_printf(cl, "Unable to parse the given bdf.\n");
return;
--
2.17.1
next parent reply other threads:[~2018-10-03 12:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <32f53ad0-92f4-4415-7a05-eff0c6fa779d@redhat.com>
2018-10-03 19:34 ` Xiaolong Ye [this message]
2018-10-03 13:31 ` Maxime Coquelin
2018-10-03 20:28 ` Ye Xiaolong
2018-10-03 14:13 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181003193439.108373-1-xiaolong.ye@intel.com \
--to=xiaolong.ye@intel.com \
--cc=dev@dpdk.org \
--cc=haiyue.wang@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=roszenrami@gmail.com \
--cc=tiwei.bie@intel.com \
--cc=xiao.w.wang@intel.com \
--cc=zhihong.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).