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>
This commit is contained in:
Bruce Richardson 2019-04-03 15:45:05 +01:00 committed by Thomas Monjalon
parent f9acaf84e9
commit 6723c0fc72
53 changed files with 201 additions and 173 deletions

View File

@ -2,6 +2,7 @@
* Copyright(c) 2010-2014 Intel Corporation
*/
#include <rte_string_fns.h>
#include <rte_acl.h>
#include <getopt.h>
#include <string.h>
@ -928,7 +929,7 @@ print_usage(const char *prgname)
n += rc;
}
snprintf(buf + n, sizeof(buf) - n, "%s", acl_alg[i].name);
strlcpy(buf + n, acl_alg[i].name, sizeof(buf) - n);
fprintf(stdout,
PRINT_USAGE_START

View File

@ -7,6 +7,7 @@
#include <inttypes.h>
#include <getopt.h>
#include <rte_string_fns.h>
#include <rte_common.h>
#include <rte_eventdev.h>
#include <rte_lcore.h>
@ -120,7 +121,7 @@ evt_parse_timer_prod_type_burst(struct evt_options *opt,
static int
evt_parse_test_name(struct evt_options *opt, const char *arg)
{
snprintf(opt->test_name, EVT_TEST_NAME_MAX_LEN, "%s", arg);
strlcpy(opt->test_name, arg, EVT_TEST_NAME_MAX_LEN);
return 0;
}

View File

@ -13,6 +13,7 @@
#include <arpa/inet.h>
#include <sys/socket.h>
#include <rte_string_fns.h>
#include <rte_common.h>
#include <rte_eth_ctrl.h>
#include <rte_ethdev.h>
@ -4694,7 +4695,7 @@ comp_boolean(struct context *ctx, const struct token *token,
(void)token;
for (i = 0; boolean_name[i]; ++i)
if (buf && i == ent)
return snprintf(buf, size, "%s", boolean_name[i]);
return strlcpy(buf, boolean_name[i], size);
if (buf)
return -1;
return i;
@ -4711,8 +4712,8 @@ comp_action(struct context *ctx, const struct token *token,
(void)token;
for (i = 0; next_action[i]; ++i)
if (buf && i == ent)
return snprintf(buf, size, "%s",
token_list[next_action[i]].name);
return strlcpy(buf, token_list[next_action[i]].name,
size);
if (buf)
return -1;
return i;
@ -4776,7 +4777,7 @@ comp_vc_action_rss_type(struct context *ctx, const struct token *token,
if (!buf)
return i + 1;
if (ent < i)
return snprintf(buf, size, "%s", rss_type_table[ent].str);
return strlcpy(buf, rss_type_table[ent].str, size);
if (ent == i)
return snprintf(buf, size, "end");
return -1;
@ -4961,7 +4962,7 @@ cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
if (index >= i)
return -1;
token = &token_list[list[index]];
snprintf(dst, size, "%s", token->name);
strlcpy(dst, token->name, size);
/* Save index for cmd_flow_get_help(). */
ctx->prev = list[index];
return 0;
@ -4978,7 +4979,7 @@ cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
if (!size)
return -1;
/* Set token type and update global help with details. */
snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
if (token->help)
cmd_flow.help_str = token->help;
else

View File

@ -2,6 +2,7 @@
* Copyright(c) 2010-2014 Intel Corporation
*/
#include <rte_string_fns.h>
#include <rte_hexdump.h>
#include "test_table.h"
#include "test_table_acl.h"
@ -467,7 +468,7 @@ setup_acl_pipeline(void)
memset(&keys[n], 0, sizeof(struct rte_table_acl_rule_add_params));
key_array[n] = &keys[n];
snprintf(line, sizeof(line), "%s", lines[n]);
strlcpy(line, lines[n], sizeof(line));
printf("PARSING [%s]\n", line);
ret = parser(line, &keys[n]);
@ -509,7 +510,7 @@ setup_acl_pipeline(void)
memset(&keys[n], 0, sizeof(struct rte_table_acl_rule_delete_params));
key_array[n] = &keys[n];
snprintf(line, sizeof(line), "%s", lines[n]);
strlcpy(line, lines[n], sizeof(line));
printf("PARSING [%s]\n", line);
ret = parse_cb_ipv4_rule_del(line, &keys[n]);
@ -545,7 +546,7 @@ setup_acl_pipeline(void)
parser = parse_cb_ipv4_rule;
for (n = 1; n <= 5; n++) {
snprintf(line, sizeof(line), "%s", lines[n-1]);
strlcpy(line, lines[n - 1], sizeof(line));
printf("PARSING [%s]\n", line);
ret = parser(line, &rule_params);
@ -571,7 +572,7 @@ setup_acl_pipeline(void)
/* delete a few rules */
for (n = 2; n <= 3; n++) {
snprintf(line, sizeof(line), "%s", lines[n-1]);
strlcpy(line, lines[n - 1], sizeof(line));
printf("PARSING [%s]\n", line);
ret = parser(line, &rule_params);
@ -598,7 +599,7 @@ setup_acl_pipeline(void)
/* Try to add duplicates */
for (n = 1; n <= 5; n++) {
snprintf(line, sizeof(line), "%s", lines[n-1]);
strlcpy(line, lines[n - 1], sizeof(line));
printf("PARSING [%s]\n", line);
ret = parser(line, &rule_params);

View File

@ -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);

View File

@ -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;

View File

@ -4,6 +4,7 @@
#include <string.h>
#include <rte_string_fns.h>
#include <rte_common.h>
#include <rte_malloc.h>
#include <rte_cryptodev_pmd.h>
@ -614,7 +615,7 @@ aesni_mb_pmd_qp_create_processed_ops_ring(struct aesni_mb_qp *qp,
struct rte_ring *r;
char ring_name[RTE_CRYPTODEV_NAME_MAX_LEN];
unsigned int n = snprintf(ring_name, sizeof(ring_name), "%s", qp->name);
unsigned int n = strlcpy(ring_name, qp->name, sizeof(ring_name));
if (n >= sizeof(ring_name))
return NULL;

View File

@ -2,6 +2,7 @@
* Copyright(c) 2018 Advanced Micro Devices, Inc. All rights reserved.
*/
#include <rte_string_fns.h>
#include <rte_bus_pci.h>
#include <rte_bus_vdev.h>
#include <rte_common.h>
@ -298,9 +299,8 @@ cryptodev_ccp_create(const char *name,
uint8_t cryptodev_cnt = 0;
if (init_params->def_p.name[0] == '\0')
snprintf(init_params->def_p.name,
sizeof(init_params->def_p.name),
"%s", name);
strlcpy(init_params->def_p.name, name,
sizeof(init_params->def_p.name));
dev = rte_cryptodev_pmd_create(init_params->def_p.name,
&vdev->device,

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2017 Intel Corporation
*/
#include <rte_string_fns.h>
#include <rte_reorder.h>
#include <rte_cryptodev.h>
#include <rte_cryptodev_pmd.h>
@ -443,8 +444,7 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
RTE_CRYPTODEV_NAME_MAX_LEN);
return -EINVAL;
}
snprintf(sched_ctx->name, sizeof(sched_ctx->name), "%s",
scheduler->name);
strlcpy(sched_ctx->name, scheduler->name, sizeof(sched_ctx->name));
if (strlen(scheduler->description) >
RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN - 1) {
@ -453,8 +453,8 @@ rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN - 1);
return -EINVAL;
}
snprintf(sched_ctx->description, sizeof(sched_ctx->description), "%s",
scheduler->description);
strlcpy(sched_ctx->description, scheduler->description,
sizeof(sched_ctx->description));
/* load scheduler instance operations functions */
sched_ctx->ops.config_queue_pair = scheduler->ops->config_queue_pair;

View File

@ -7,6 +7,7 @@
#include <stdint.h>
#include <stdio.h>
#include <rte_string_fns.h>
#include <rte_branch_prediction.h>
#include <rte_debug.h>
#include <rte_lcore.h>
@ -944,7 +945,7 @@ opdl_ring_create(const char *name, uint32_t num_slots, uint32_t slot_size,
/* Initialise opdl_ring queue */
memset(t, 0, sizeof(*t));
snprintf(t->name, sizeof(t->name), "%s", name);
strlcpy(t->name, name, sizeof(t->name));
t->socket = socket;
t->num_slots = num_slots;
t->mask = num_slots - 1;

View File

@ -6,6 +6,7 @@
* All rights reserved.
*/
#include <rte_string_fns.h>
#include <rte_mbuf.h>
#include <rte_ethdev_driver.h>
#include <rte_ethdev_vdev.h>
@ -442,7 +443,7 @@ eth_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
if (s < 0)
return -EINVAL;
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", internals->if_name);
strlcpy(ifr.ifr_name, internals->if_name, IFNAMSIZ);
ret = ioctl(s, SIOCSIFMTU, &ifr);
close(s);
@ -462,7 +463,7 @@ eth_dev_change_flags(char *if_name, uint32_t flags, uint32_t mask)
if (s < 0)
return;
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", if_name);
strlcpy(ifr.ifr_name, if_name, IFNAMSIZ);
if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
goto out;
ifr.ifr_flags &= mask;

View File

@ -7,6 +7,7 @@
#include <locale.h>
#include <unistd.h>
#include <rte_string_fns.h>
#include <rte_ethdev_driver.h>
#include <rte_malloc.h>
@ -347,7 +348,7 @@ set_arg(char *arg, char *val)
o->v.INT = atoll(val);
break;
case OTSTRING:
snprintf(o->v.STR, ARK_MAX_STR_LEN, "%s", val);
strlcpy(o->v.STR, val, ARK_MAX_STR_LEN);
break;
}
return 1;

View File

@ -7,6 +7,7 @@
#include <locale.h>
#include <unistd.h>
#include <rte_string_fns.h>
#include <rte_eal.h>
#include <rte_ethdev_driver.h>
@ -329,7 +330,7 @@ pmd_set_arg(char *arg, char *val)
o->v.INT = atoll(val);
break;
case OTSTRING:
snprintf(o->v.STR, ARK_MAX_STR_LEN, "%s", val);
strlcpy(o->v.STR, val, ARK_MAX_STR_LEN);
break;
}
return 1;

View File

@ -2,6 +2,7 @@
* Copyright(c) 2018 Aquantia Corporation
*/
#include <rte_string_fns.h>
#include <rte_ethdev_pci.h>
#include "atl_ethdev.h"
@ -755,8 +756,8 @@ atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
return RTE_DIM(atl_xstats_tbl);
for (i = 0; i < size && i < RTE_DIM(atl_xstats_tbl); i++)
snprintf(xstats_names[i].name, RTE_ETH_XSTATS_NAME_SIZE, "%s",
atl_xstats_tbl[i].name);
strlcpy(xstats_names[i].name, atl_xstats_tbl[i].name,
RTE_ETH_XSTATS_NAME_SIZE);
return i;
}

View File

@ -8,6 +8,7 @@
#include "bnx2x.h"
#include "bnx2x_rxtx.h"
#include <rte_string_fns.h>
#include <rte_dev.h>
#include <rte_ethdev_pci.h>
#include <rte_alarm.h>
@ -445,10 +446,9 @@ bnx2x_get_xstats_names(__rte_unused struct rte_eth_dev *dev,
if (xstats_names != NULL)
for (i = 0; i < stat_cnt; i++)
snprintf(xstats_names[i].name,
sizeof(xstats_names[i].name),
"%s",
bnx2x_xstats_strings[i].name);
strlcpy(xstats_names[i].name,
bnx2x_xstats_strings[i].name,
sizeof(xstats_names[i].name));
return stat_cnt;
}

View File

@ -5,6 +5,7 @@
#include <inttypes.h>
#include <rte_string_fns.h>
#include <rte_byteorder.h>
#include "bnxt.h"
@ -491,41 +492,36 @@ int bnxt_dev_xstats_get_names_op(__rte_unused struct rte_eth_dev *eth_dev,
count = 0;
for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s",
bnxt_rx_stats_strings[i].name);
strlcpy(xstats_names[count].name,
bnxt_rx_stats_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}
for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s",
bnxt_tx_stats_strings[i].name);
strlcpy(xstats_names[count].name,
bnxt_tx_stats_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s",
bnxt_func_stats_strings[4].name);
strlcpy(xstats_names[count].name,
bnxt_func_stats_strings[4].name,
sizeof(xstats_names[count].name));
count++;
for (i = 0; i < RTE_DIM(bnxt_rx_ext_stats_strings); i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s",
bnxt_rx_ext_stats_strings[i].name);
strlcpy(xstats_names[count].name,
bnxt_rx_ext_stats_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}
for (i = 0; i < RTE_DIM(bnxt_tx_ext_stats_strings); i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s",
bnxt_tx_ext_stats_strings[i].name);
strlcpy(xstats_names[count].name,
bnxt_tx_ext_stats_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}

View File

@ -15,6 +15,7 @@
#include <sys/types.h>
#include <sys/syscall.h>
#include <rte_string_fns.h>
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_interrupts.h>
@ -439,10 +440,9 @@ dpaa_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
if (xstats_names != NULL)
for (i = 0; i < stat_cnt; i++)
snprintf(xstats_names[i].name,
sizeof(xstats_names[i].name),
"%s",
dpaa_xstats_strings[i].name);
strlcpy(xstats_names[i].name,
dpaa_xstats_strings[i].name,
sizeof(xstats_names[i].name));
return stat_cnt;
}

View File

@ -8,6 +8,7 @@
#include <stdint.h>
#include <stdarg.h>
#include <rte_string_fns.h>
#include <rte_common.h>
#include <rte_interrupts.h>
#include <rte_byteorder.h>
@ -1904,8 +1905,8 @@ static int eth_igb_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
/* Note: limit checked in rte_eth_xstats_names() */
for (i = 0; i < IGB_NB_XSTATS; i++) {
snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
"%s", rte_igb_stats_strings[i].name);
strlcpy(xstats_names[i].name, rte_igb_stats_strings[i].name,
sizeof(xstats_names[i].name));
}
return IGB_NB_XSTATS;
@ -1922,9 +1923,9 @@ static int eth_igb_xstats_get_names_by_id(struct rte_eth_dev *dev,
return IGB_NB_XSTATS;
for (i = 0; i < IGB_NB_XSTATS; i++)
snprintf(xstats_names[i].name,
sizeof(xstats_names[i].name),
"%s", rte_igb_stats_strings[i].name);
strlcpy(xstats_names[i].name,
rte_igb_stats_strings[i].name,
sizeof(xstats_names[i].name));
return IGB_NB_XSTATS;
@ -2071,9 +2072,9 @@ static int eth_igbvf_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
if (xstats_names != NULL)
for (i = 0; i < IGBVF_NB_XSTATS; i++) {
snprintf(xstats_names[i].name,
sizeof(xstats_names[i].name), "%s",
rte_igbvf_stats_strings[i].name);
strlcpy(xstats_names[i].name,
rte_igbvf_stats_strings[i].name,
sizeof(xstats_names[i].name));
}
return IGBVF_NB_XSTATS;
}

View File

@ -31,6 +31,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <rte_string_fns.h>
#include <rte_ether.h>
#include <rte_ethdev_driver.h>
#include <rte_ethdev_pci.h>
@ -421,13 +422,11 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev)
host_info->os_type = ENA_ADMIN_OS_DPDK;
host_info->kernel_ver = RTE_VERSION;
snprintf((char *)host_info->kernel_ver_str,
sizeof(host_info->kernel_ver_str),
"%s", rte_version());
strlcpy((char *)host_info->kernel_ver_str, rte_version(),
sizeof(host_info->kernel_ver_str));
host_info->os_dist = RTE_VERSION;
snprintf((char *)host_info->os_dist_str,
sizeof(host_info->os_dist_str),
"%s", rte_version());
strlcpy((char *)host_info->os_dist_str, rte_version(),
sizeof(host_info->os_dist_str));
host_info->driver_version =
(DRV_MODULE_VER_MAJOR) |
(DRV_MODULE_VER_MINOR << ENA_ADMIN_HOST_INFO_MINOR_SHIFT) |

View File

@ -3,6 +3,7 @@
* Copyright 2017 Mellanox Technologies, Ltd
*/
#include <rte_string_fns.h>
#include <rte_malloc.h>
#include "failsafe_private.h"
@ -84,8 +85,9 @@ fs_bus_init(struct rte_eth_dev *dev)
snprintf(devstr, sizeof(devstr), "%s,%s",
probed_da->name, probed_da->args);
else
snprintf(devstr, sizeof(devstr), "%s",
rte_eth_devices[pid].device->name);
strlcpy(devstr,
rte_eth_devices[pid].device->name,
sizeof(devstr));
ret = rte_devargs_parse(da, devstr);
if (ret) {
ERROR("Probed devargs parsing failed with code"

View File

@ -2,6 +2,7 @@
* Copyright(c) 2010-2017 Intel Corporation
*/
#include <rte_string_fns.h>
#include <rte_malloc.h>
#include <rte_tailq.h>
@ -1983,8 +1984,8 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
for (i = j = 0; i < nb_rec; j++) {
pinfo[j].proto_id = tlv->data[0];
snprintf(pinfo[j].name, I40E_DDP_NAME_SIZE, "%s",
(const char *)&tlv->data[1]);
strlcpy(pinfo[j].name, (const char *)&tlv->data[1],
I40E_DDP_NAME_SIZE);
i += tlv->len;
tlv = &tlv[tlv->len];
}

View File

@ -2,6 +2,7 @@
* Copyright(c) 2018 Intel Corporation
*/
#include <rte_string_fns.h>
#include <rte_ethdev_pci.h>
#include <stdio.h>
@ -3437,17 +3438,15 @@ static int ice_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
/* Get stats from ice_eth_stats struct */
for (i = 0; i < ICE_NB_ETH_XSTATS; i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s", ice_stats_strings[i].name);
strlcpy(xstats_names[count].name, ice_stats_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}
/* Get individiual stats from ice_hw_port struct */
for (i = 0; i < ICE_NB_HW_PORT_XSTATS; i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s", ice_hw_port_strings[i].name);
strlcpy(xstats_names[count].name, ice_hw_port_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}

View File

@ -11,6 +11,7 @@
#include <stdarg.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <rte_string_fns.h>
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_cycles.h>
@ -3293,19 +3294,17 @@ static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
/* Extended stats from ixgbe_hw_stats */
for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s",
rte_ixgbe_stats_strings[i].name);
strlcpy(xstats_names[count].name,
rte_ixgbe_stats_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}
/* MACsec Stats */
for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s",
rte_ixgbe_macsec_strings[i].name);
strlcpy(xstats_names[count].name,
rte_ixgbe_macsec_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}
@ -3353,19 +3352,17 @@ static int ixgbe_dev_xstats_get_names_by_id(
/* Extended stats from ixgbe_hw_stats */
for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s",
rte_ixgbe_stats_strings[i].name);
strlcpy(xstats_names[count].name,
rte_ixgbe_stats_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}
/* MACsec Stats */
for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s",
rte_ixgbe_macsec_strings[i].name);
strlcpy(xstats_names[count].name,
rte_ixgbe_macsec_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}
@ -3422,9 +3419,9 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
if (xstats_names != NULL)
for (i = 0; i < IXGBEVF_NB_XSTATS; i++)
snprintf(xstats_names[i].name,
sizeof(xstats_names[i].name),
"%s", rte_ixgbevf_stats_strings[i].name);
strlcpy(xstats_names[i].name,
rte_ixgbevf_stats_strings[i].name,
sizeof(xstats_names[i].name));
return IXGBEVF_NB_XSTATS;
}

View File

@ -6,6 +6,7 @@
#include <pthread.h>
#include <unistd.h>
#include <rte_string_fns.h>
#include <rte_ethdev_driver.h>
#include <rte_ethdev_vdev.h>
#include <rte_kni.h>
@ -126,7 +127,7 @@ eth_kni_start(struct rte_eth_dev *dev)
const char *name = dev->device->name + 4; /* remove net_ */
mb_pool = internals->rx_queues[0].mb_pool;
snprintf(conf.name, RTE_KNI_NAMESIZE, "%s", name);
strlcpy(conf.name, name, RTE_KNI_NAMESIZE);
conf.force_bind = 0;
conf.group_id = port_id;
conf.mbuf_size =

View File

@ -2,6 +2,7 @@
* Copyright(c) 2017 Cavium, Inc
*/
#include <rte_string_fns.h>
#include <rte_ethdev_driver.h>
#include <rte_ethdev_pci.h>
#include <rte_cycles.h>
@ -1781,8 +1782,8 @@ lio_dev_configure(struct rte_eth_dev *eth_dev)
goto nic_config_fail;
}
snprintf(lio_dev->firmware_version, LIO_FW_VERSION_LENGTH, "%s",
resp->cfg_info.lio_firmware_version);
strlcpy(lio_dev->firmware_version,
resp->cfg_info.lio_firmware_version, LIO_FW_VERSION_LENGTH);
lio_swap_8B_data((uint64_t *)(&resp->cfg_info),
sizeof(struct octeon_if_cfg_info) >> 3);

View File

@ -4,6 +4,7 @@
* All rights reserved.
*/
#include <rte_string_fns.h>
#include <rte_ethdev_driver.h>
#include <rte_kvargs.h>
#include <rte_bus_vdev.h>
@ -347,7 +348,7 @@ mvneta_dev_start(struct rte_eth_dev *dev)
if (priv->ppio)
return mvneta_dev_set_link_up(dev);
snprintf(match, sizeof(match), "%s", dev->data->name);
strlcpy(match, dev->data->name, sizeof(match));
priv->ppio_params.match = match;
priv->ppio_params.inqs_params.mtu = dev->data->mtu;

View File

@ -4,6 +4,7 @@
* All rights reserved.
*/
#include <rte_string_fns.h>
#include <rte_ethdev_driver.h>
#include <rte_kvargs.h>
#include <rte_log.h>
@ -1388,8 +1389,8 @@ mrvl_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
return RTE_DIM(mrvl_xstats_tbl);
for (i = 0; i < size && i < RTE_DIM(mrvl_xstats_tbl); i++)
snprintf(xstats_names[i].name, RTE_ETH_XSTATS_NAME_SIZE, "%s",
mrvl_xstats_tbl[i].name);
strlcpy(xstats_names[i].name, mrvl_xstats_tbl[i].name,
RTE_ETH_XSTATS_NAME_SIZE);
return size;
}

View File

@ -5,6 +5,7 @@
*/
#include "qede_ethdev.h"
#include <rte_string_fns.h>
#include <rte_alarm.h>
#include <rte_version.h>
#include <rte_kvargs.h>
@ -1591,27 +1592,24 @@ qede_get_xstats_names(struct rte_eth_dev *dev,
if (xstats_names != NULL) {
for (i = 0; i < RTE_DIM(qede_xstats_strings); i++) {
snprintf(xstats_names[stat_idx].name,
sizeof(xstats_names[stat_idx].name),
"%s",
qede_xstats_strings[i].name);
strlcpy(xstats_names[stat_idx].name,
qede_xstats_strings[i].name,
sizeof(xstats_names[stat_idx].name));
stat_idx++;
}
if (ECORE_IS_BB(edev)) {
for (i = 0; i < RTE_DIM(qede_bb_xstats_strings); i++) {
snprintf(xstats_names[stat_idx].name,
sizeof(xstats_names[stat_idx].name),
"%s",
qede_bb_xstats_strings[i].name);
strlcpy(xstats_names[stat_idx].name,
qede_bb_xstats_strings[i].name,
sizeof(xstats_names[stat_idx].name));
stat_idx++;
}
} else {
for (i = 0; i < RTE_DIM(qede_ah_xstats_strings); i++) {
snprintf(xstats_names[stat_idx].name,
sizeof(xstats_names[stat_idx].name),
"%s",
qede_ah_xstats_strings[i].name);
strlcpy(xstats_names[stat_idx].name,
qede_ah_xstats_strings[i].name,
sizeof(xstats_names[stat_idx].name));
stat_idx++;
}
}

View File

@ -11,6 +11,7 @@
#include <string.h>
#include <errno.h>
#include <rte_string_fns.h>
#include <rte_fbarray.h>
#include <rte_eal_memconfig.h>
@ -424,7 +425,7 @@ vhost_user_setup(struct virtio_user_dev *dev)
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
snprintf(un.sun_path, sizeof(un.sun_path), "%s", dev->path);
strlcpy(un.sun_path, dev->path, sizeof(un.sun_path));
if (dev->is_server) {
dev->listenfd = fd;

View File

@ -13,6 +13,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <rte_string_fns.h>
#include <rte_eal_memconfig.h>
#include "vhost.h"
@ -429,7 +430,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
int server, int mrg_rxbuf, int in_order, int packed_vq)
{
pthread_mutex_init(&dev->mutex, NULL);
snprintf(dev->path, PATH_MAX, "%s", path);
strlcpy(dev->path, path, PATH_MAX);
dev->started = 0;
dev->max_queue_pairs = queues;
dev->queue_pairs = 1; /* mq disabled by default */

View File

@ -4,6 +4,7 @@
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <rte_string_fns.h>
#include <rte_version.h>
#include <rte_ethdev.h>
#include <rte_ether.h>
@ -43,10 +44,9 @@ rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo)
memset(&dev_info, 0, sizeof(dev_info));
rte_eth_dev_info_get(port_id, &dev_info);
snprintf(drvinfo->driver, sizeof(drvinfo->driver), "%s",
dev_info.driver_name);
snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
rte_version());
strlcpy(drvinfo->driver, dev_info.driver_name,
sizeof(drvinfo->driver));
strlcpy(drvinfo->version, rte_version(), sizeof(drvinfo->version));
/* TODO: replace bus_info by rte_devargs.name */
if (dev_info.device)
bus = rte_bus_find_by_device(dev_info.device);

View File

@ -19,6 +19,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <rte_string_fns.h>
#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_common.h>
@ -1199,8 +1200,7 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,
if (strcmp(lgopts[option_index].name, "cdev_type") == 0) {
retval = parse_cryptodev_type(&options->type, optarg);
if (retval == 0)
snprintf(options->string_type, MAX_STR_LEN,
"%s", optarg);
strlcpy(options->string_type, optarg, MAX_STR_LEN);
return retval;
}

View File

@ -17,6 +17,7 @@
#include <sys/socket.h>
#include <sys/select.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
#include <rte_memory.h>
#include <rte_mempool.h>
@ -415,7 +416,7 @@ add_all_channels(const char *vm_name)
!strncmp(dir->d_name, "..", 2))
continue;
snprintf(socket_name, sizeof(socket_name), "%s", dir->d_name);
strlcpy(socket_name, dir->d_name, sizeof(socket_name));
remaining = socket_name;
/* Extract vm_name from "<vm_name>.<channel_num>" */
token = strsep(&remaining, ".");
@ -562,8 +563,8 @@ add_host_channel(void)
"channel '%s'\n", socket_path);
return 0;
}
snprintf(chan_info->channel_path,
sizeof(chan_info->channel_path), "%s", socket_path);
strlcpy(chan_info->channel_path, socket_path,
sizeof(chan_info->channel_path));
if (setup_host_channel_info(&chan_info, 0) < 0) {
rte_free(chan_info);
return 0;

View File

@ -21,6 +21,7 @@
#else
#pragma message "Jansson dev libs unavailable, not including JSON parsing"
#endif
#include <rte_string_fns.h>
#include <rte_log.h>
#include <rte_memory.h>
#include <rte_malloc.h>
@ -161,7 +162,7 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt)
strcpy(pkt->vm_name, json_string_value(value));
} else if (!strcmp(key, "command")) {
char command[32];
snprintf(command, 32, "%s", json_string_value(value));
strlcpy(command, json_string_value(value), 32);
if (!strcmp(command, "power")) {
pkt->command = CPU_POWER;
} else if (!strcmp(command, "create")) {
@ -175,7 +176,7 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt)
}
} else if (!strcmp(key, "policy_type")) {
char command[32];
snprintf(command, 32, "%s", json_string_value(value));
strlcpy(command, json_string_value(value), 32);
if (!strcmp(command, "TIME")) {
pkt->policy_to_use = TIME;
} else if (!strcmp(command, "TRAFFIC")) {
@ -191,7 +192,7 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt)
}
} else if (!strcmp(key, "workload")) {
char command[32];
snprintf(command, 32, "%s", json_string_value(value));
strlcpy(command, json_string_value(value), 32);
if (!strcmp(command, "HIGH")) {
pkt->workload = HIGH;
} else if (!strcmp(command, "MEDIUM")) {
@ -237,8 +238,9 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt)
for (i = 0; i < size; i++) {
char mac[32];
snprintf(mac, 32, "%s", json_string_value(
json_array_get(value, i)));
strlcpy(mac,
json_string_value(json_array_get(value, i)),
32);
set_policy_mac(pkt, i, mac);
}
pkt->nb_mac_to_monitor = size;
@ -250,7 +252,7 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt)
(uint32_t)json_integer_value(value);
} else if (!strcmp(key, "unit")) {
char unit[32];
snprintf(unit, 32, "%s", json_string_value(value));
strlcpy(unit, json_string_value(value), 32);
if (!strcmp(unit, "SCALE_UP")) {
pkt->unit = CPU_POWER_SCALE_UP;
} else if (!strcmp(unit, "SCALE_DOWN")) {

View File

@ -2,6 +2,7 @@
* Copyright(c) 2010-2014 Intel Corporation
*/
#include <rte_string_fns.h>
#include <rte_acl.h>
#include "acl.h"
@ -249,7 +250,7 @@ rte_acl_create(const struct rte_acl_param *param)
ctx->rule_sz = param->rule_size;
ctx->socket_id = param->socket_id;
ctx->alg = rte_acl_default_classify;
snprintf(ctx->name, sizeof(ctx->name), "%s", param->name);
strlcpy(ctx->name, param->name, sizeof(ctx->name));
te->data = (void *) ctx;

View File

@ -6,6 +6,7 @@
#include <string.h>
#include <stdbool.h>
#include <rte_string_fns.h>
#include <rte_compat.h>
#include <rte_common.h>
#include <rte_errno.h>
@ -214,7 +215,7 @@ rte_bbdev_allocate(const char *name)
bbdev->data->dev_id = dev_id;
bbdev->state = RTE_BBDEV_INITIALIZED;
ret = snprintf(bbdev->data->name, RTE_BBDEV_NAME_MAX_LEN, "%s", name);
ret = strlcpy(bbdev->data->name, name, RTE_BBDEV_NAME_MAX_LEN);
if ((ret < 0) || (ret >= RTE_BBDEV_NAME_MAX_LEN)) {
rte_bbdev_log(ERR, "Copying device name \"%s\" failed", name);
return NULL;

View File

@ -7,6 +7,7 @@
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <rte_string_fns.h>
#include <rte_common.h>
#include "rte_cfgfile.h"
@ -113,9 +114,8 @@ _add_entry(struct rte_cfgfile_section *section, const char *entryname,
struct rte_cfgfile_entry *curr_entry =
&section->entries[section->num_entries];
snprintf(curr_entry->name, sizeof(curr_entry->name), "%s", entryname);
snprintf(curr_entry->value,
sizeof(curr_entry->value), "%s", entryvalue);
strlcpy(curr_entry->name, entryname, sizeof(curr_entry->name));
strlcpy(curr_entry->value, entryvalue, sizeof(curr_entry->value));
section->num_entries++;
return 0;
@ -341,8 +341,8 @@ rte_cfgfile_add_section(struct rte_cfgfile *cfg, const char *sectionname)
cfg->allocated_sections += CFG_ALLOC_SECTION_BATCH;
}
snprintf(cfg->sections[cfg->num_sections].name,
sizeof(cfg->sections[0].name), "%s", sectionname);
strlcpy(cfg->sections[cfg->num_sections].name, sectionname,
sizeof(cfg->sections[0].name));
cfg->sections[cfg->num_sections].num_entries = 0;
cfg->num_sections++;
@ -392,9 +392,8 @@ int rte_cfgfile_set_entry(struct rte_cfgfile *cfg, const char *sectionname,
for (i = 0; i < curr_section->num_entries; i++)
if (!strcmp(curr_section->entries[i].name, entryname)) {
snprintf(curr_section->entries[i].value,
sizeof(curr_section->entries[i].value),
"%s", entryvalue);
strlcpy(curr_section->entries[i].value, entryvalue,
sizeof(curr_section->entries[i].value));
return 0;
}
printf("Error - entry name doesn't exist\n");
@ -468,8 +467,7 @@ rte_cfgfile_sections(struct rte_cfgfile *cfg, char *sections[],
int i;
for (i = 0; i < cfg->num_sections && i < max_sections; i++)
snprintf(sections[i], CFG_NAME_LEN, "%s",
cfg->sections[i].name);
strlcpy(sections[i], cfg->sections[i].name, CFG_NAME_LEN);
return i;
}
@ -499,7 +497,7 @@ rte_cfgfile_section_num_entries_by_index(struct rte_cfgfile *cfg,
const struct rte_cfgfile_section *sect = &(cfg->sections[index]);
snprintf(sectionname, CFG_NAME_LEN, "%s", sect->name);
strlcpy(sectionname, sect->name, CFG_NAME_LEN);
return sect->num_entries;
}
int
@ -526,7 +524,7 @@ rte_cfgfile_section_entries_by_index(struct rte_cfgfile *cfg, int index,
if (index < 0 || index >= cfg->num_sections)
return -1;
sect = &cfg->sections[index];
snprintf(sectionname, CFG_NAME_LEN, "%s", sect->name);
strlcpy(sectionname, sect->name, CFG_NAME_LEN);
for (i = 0; i < max_entries && i < sect->num_entries; i++)
entries[i] = sect->entries[i];
return i;

View File

@ -7,6 +7,7 @@
#include <stdio.h>
#include <inttypes.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
#include <rte_eal.h>
#include <rte_memzone.h>
@ -252,8 +253,8 @@ rte_compressdev_pmd_allocate(const char *name, int socket_id)
compressdev->data = compressdev_data;
snprintf(compressdev->data->name, RTE_COMPRESSDEV_NAME_MAX_LEN,
"%s", name);
strlcpy(compressdev->data->name, name,
RTE_COMPRESSDEV_NAME_MAX_LEN);
compressdev->data->dev_id = dev_id;
compressdev->data->socket_id = socket_id;

View File

@ -2,6 +2,7 @@
* Copyright(c) 2017-2018 Intel Corporation
*/
#include <rte_string_fns.h>
#include <rte_malloc.h>
#include <rte_kvargs.h>
#include <rte_eal.h>
@ -21,7 +22,7 @@ rte_compressdev_pmd_parse_name_arg(const char *key __rte_unused,
struct rte_compressdev_pmd_init_params *params = extra_args;
int n;
n = snprintf(params->name, RTE_COMPRESSDEV_NAME_MAX_LEN, "%s", value);
n = strlcpy(params->name, value, RTE_COMPRESSDEV_NAME_MAX_LEN);
if (n >= RTE_COMPRESSDEV_NAME_MAX_LEN)
return -EINVAL;

View File

@ -2,6 +2,7 @@
* Copyright(c) 2017 Intel Corporation
*/
#include <rte_string_fns.h>
#include <rte_malloc.h>
#include "rte_cryptodev_pmd.h"
@ -16,7 +17,7 @@ rte_cryptodev_pmd_parse_name_arg(const char *key __rte_unused,
struct rte_cryptodev_pmd_init_params *params = extra_args;
int n;
n = snprintf(params->name, RTE_CRYPTODEV_NAME_MAX_LEN, "%s", value);
n = strlcpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN);
if (n >= RTE_CRYPTODEV_NAME_MAX_LEN)
return -EINVAL;

View File

@ -16,6 +16,7 @@
#include <sys/stat.h>
#include <dirent.h>
#include <rte_string_fns.h>
#include <rte_eal.h>
#include <rte_log.h>
#include <rte_lcore.h>
@ -139,7 +140,7 @@ eal_option_device_add(enum rte_devtype type, const char *optarg)
}
devopt->type = type;
ret = snprintf(devopt->arg, optlen, "%s", optarg);
ret = strlcpy(devopt->arg, optarg, optlen);
if (ret < 0) {
RTE_LOG(ERR, EAL, "Unable to copy device option\n");
free(devopt);

View File

@ -9,6 +9,7 @@
#include <stdarg.h>
#include <sys/queue.h>
#include <rte_string_fns.h>
#include <rte_log.h>
#include <rte_eal_memconfig.h>
#include <rte_errno.h>
@ -591,7 +592,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
goto error_unlock_exit;
}
table->keys = key_array;
snprintf(table->name, sizeof(table->name), "%s", name);
strlcpy(table->name, name, sizeof(table->name));
RTE_LOG(DEBUG, EFD, "Creating an EFD table with %u chunks,"
" which potentially supports %u entries\n",

View File

@ -13,6 +13,7 @@
#include <sys/types.h>
#include <sys/queue.h>
#include <rte_string_fns.h>
#include <rte_byteorder.h>
#include <rte_log.h>
#include <rte_debug.h>
@ -1362,8 +1363,7 @@ rte_event_pmd_allocate(const char *name, int socket_id)
eventdev->data = eventdev_data;
snprintf(eventdev->data->name, RTE_EVENTDEV_NAME_MAX_LEN,
"%s", name);
strlcpy(eventdev->data->name, name, RTE_EVENTDEV_NAME_MAX_LEN);
eventdev->data->dev_id = dev_id;
eventdev->data->socket_id = socket_id;

View File

@ -2,6 +2,7 @@
* Copyright(c) 2017 Intel Corporation
*/
#include <rte_string_fns.h>
#include <rte_compat.h>
#include <rte_flow_classify.h>
#include "rte_flow_classify_parse.h"
@ -285,8 +286,7 @@ rte_flow_classifier_create(struct rte_flow_classifier_params *params)
}
/* Save input parameters */
snprintf(cls->name, RTE_FLOW_CLASSIFIER_MAX_NAME_SZ, "%s",
params->name);
strlcpy(cls->name, params->name, RTE_FLOW_CLASSIFIER_MAX_NAME_SZ);
cls->socket_id = params->socket_id;

View File

@ -6,6 +6,7 @@
#include <stdlib.h>
#include <errno.h>
#include <rte_string_fns.h>
#include <rte_errno.h>
#include <rte_common.h>
#include <rte_eal.h>
@ -240,7 +241,7 @@ rte_jobstats_init(struct rte_jobstats *job, const char *name,
job->target = target;
job->update_period_cb = &default_update_function;
rte_jobstats_reset(job);
snprintf(job->name, RTE_DIM(job->name), "%s", name == NULL ? "" : name);
strlcpy(job->name, name == NULL ? "" : name, RTE_DIM(job->name));
job->context = NULL;
return 0;

View File

@ -7,6 +7,7 @@
#include <stdbool.h>
#include <math.h>
#include <rte_string_fns.h>
#include <rte_mbuf.h>
#include <rte_log.h>
#include <rte_cycles.h>
@ -309,8 +310,8 @@ rte_latencystats_get_names(struct rte_metric_name *names, uint16_t size)
return NUM_LATENCY_STATS;
for (i = 0; i < NUM_LATENCY_STATS; i++)
snprintf(names[i].name, sizeof(names[i].name),
"%s", lat_stats_strings[i].name);
strlcpy(names[i].name, lat_stats_strings[i].name,
sizeof(names[i].name));
return NUM_LATENCY_STATS;
}

View File

@ -4,6 +4,7 @@
#include <string.h>
#include <rte_string_fns.h>
#include <rte_eal.h>
#include <rte_eal_memconfig.h>
#include <rte_memory.h>
@ -132,7 +133,7 @@ rte_member_create(const struct rte_member_parameters *params)
RTE_MEMBER_LOG(ERR, "Create setsummary failed\n");
goto error_unlock_exit;
}
snprintf(setsum->name, sizeof(setsum->name), "%s", params->name);
strlcpy(setsum->name, params->name, sizeof(setsum->name));
setsum->type = params->type;
setsum->socket_id = params->socket_id;
setsum->key_len = params->key_len;

View File

@ -6,6 +6,7 @@
#include <stdio.h>
#include <string.h>
#include <rte_string_fns.h>
#include <rte_mempool.h>
#include <rte_errno.h>
#include <rte_dev.h>
@ -51,7 +52,7 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
ops_index = rte_mempool_ops_table.num_ops++;
ops = &rte_mempool_ops_table.ops[ops_index];
snprintf(ops->name, sizeof(ops->name), "%s", h->name);
strlcpy(ops->name, h->name, sizeof(ops->name));
ops->alloc = h->alloc;
ops->free = h->free;
ops->enqueue = h->enqueue;

View File

@ -12,6 +12,7 @@
#include <signal.h>
#include <limits.h>
#include <rte_string_fns.h>
#include <rte_memcpy.h>
#include <rte_atomic.h>
@ -159,7 +160,7 @@ power_set_governor_userspace(struct rte_power_info *pi)
goto out;
}
/* Save the original governor */
snprintf(pi->governor_ori, sizeof(pi->governor_ori), "%s", buf);
strlcpy(pi->governor_ori, buf, sizeof(pi->governor_ori));
/* Write 'userspace' to the governor */
val = fseek(f, 0, SEEK_SET);

View File

@ -14,6 +14,7 @@
#include <errno.h>
#include <inttypes.h>
#include <rte_string_fns.h>
#include <rte_memcpy.h>
#include <rte_atomic.h>
@ -349,7 +350,7 @@ power_set_governor_performance(struct pstate_power_info *pi)
goto out;
}
/* Save the original governor */
snprintf(pi->governor_ori, sizeof(pi->governor_ori), "%s", buf);
strlcpy(pi->governor_ori, buf, sizeof(pi->governor_ori));
/* Write 'performance' to the governor */
val = fseek(f, 0, SEEK_SET);

View File

@ -13,6 +13,7 @@
#include <sys/types.h>
#include <sys/queue.h>
#include <rte_string_fns.h>
#include <rte_byteorder.h>
#include <rte_log.h>
#include <rte_debug.h>
@ -508,7 +509,7 @@ rte_rawdev_pmd_allocate(const char *name, size_t dev_priv_size, int socket_id)
rawdev->dev_id = dev_id;
rawdev->socket_id = socket_id;
rawdev->started = 0;
snprintf(rawdev->name, RTE_RAWDEV_NAME_MAX_LEN, "%s", name);
strlcpy(rawdev->name, name, RTE_RAWDEV_NAME_MAX_LEN);
rawdev->attached = RTE_RAWDEV_ATTACHED;
rawdev_globals.nb_devs++;

View File

@ -5,6 +5,7 @@
#include <inttypes.h>
#include <string.h>
#include <rte_string_fns.h>
#include <rte_log.h>
#include <rte_mbuf.h>
#include <rte_eal_memconfig.h>
@ -82,7 +83,7 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize,
}
memset(b, 0, bufsize);
snprintf(b->name, sizeof(b->name), "%s", name);
strlcpy(b->name, name, sizeof(b->name));
b->memsize = bufsize;
b->order_buf.size = b->ready_buf.size = size;
b->order_buf.mask = b->ready_buf.mask = size - 1;
@ -161,7 +162,7 @@ rte_reorder_reset(struct rte_reorder_buffer *b)
char name[RTE_REORDER_NAMESIZE];
rte_reorder_free_mbufs(b);
snprintf(name, sizeof(name), "%s", b->name);
strlcpy(name, b->name, sizeof(name));
/* No error checking as current values should be valid */
rte_reorder_init(b, b->memsize, name, b->order_buf.size);
}

View File

@ -4,6 +4,7 @@
#include <string.h>
#include <rte_string_fns.h>
#include <rte_atomic.h>
#include <rte_eal.h>
#include <rte_eal_memconfig.h>
@ -99,7 +100,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
rte_stack_init(s, count, flags);
/* Store the name for later lookups */
ret = snprintf(s->name, sizeof(s->name), "%s", name);
ret = strlcpy(s->name, name, sizeof(s->name));
if (ret < 0 || ret >= (int)sizeof(s->name)) {
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);