summaryrefslogtreecommitdiff
path: root/examples/cmdline
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/cmdline
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 'examples/cmdline')
-rw-r--r--examples/cmdline/commands.c2
-rw-r--r--examples/cmdline/parse_obj_list.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/examples/cmdline/commands.c b/examples/cmdline/commands.c
index 06916d7..e96739f 100644
--- a/examples/cmdline/commands.c
+++ b/examples/cmdline/commands.c
@@ -145,7 +145,7 @@ static void cmd_obj_add_parsed(void *parsed_result,
cmdline_printf(cl, "mem error\n");
return;
}
- snprintf(o->name, sizeof(o->name), "%s", res->name);
+ strlcpy(o->name, res->name, sizeof(o->name));
o->ip = res->ip;
SLIST_INSERT_HEAD(&global_obj_list, o, next);
diff --git a/examples/cmdline/parse_obj_list.c b/examples/cmdline/parse_obj_list.c
index 69eb448..5d29f9d 100644
--- a/examples/cmdline/parse_obj_list.c
+++ b/examples/cmdline/parse_obj_list.c
@@ -98,7 +98,7 @@ int complete_get_elt_obj_list(cmdline_parse_token_hdr_t *tk,
return -1;
if (dstbuf)
- snprintf(dstbuf, size, "%s", o->name);
+ strlcpy(dstbuf, o->name, size);
return 0;
}