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>
This commit is contained in:
Bruce Richardson 2019-04-03 15:45:04 +01:00 committed by Thomas Monjalon
parent 277b6e7ef4
commit f9acaf84e9
47 changed files with 85 additions and 89 deletions

View file

@ -189,12 +189,12 @@ parse_rxtxdev(const char *key, const char *value, void *extra_args)
struct pdump_tuples *pt = extra_args;
if (!strcmp(key, PDUMP_RX_DEV_ARG)) {
snprintf(pt->rx_dev, sizeof(pt->rx_dev), "%s", value);
strlcpy(pt->rx_dev, value, sizeof(pt->rx_dev));
/* identify the tx stream type for pcap vdev */
if (if_nametoindex(pt->rx_dev))
pt->rx_vdev_stream_type = IFACE;
} else if (!strcmp(key, PDUMP_TX_DEV_ARG)) {
snprintf(pt->tx_dev, sizeof(pt->tx_dev), "%s", value);
strlcpy(pt->tx_dev, value, sizeof(pt->tx_dev));
/* identify the tx stream type for pcap vdev */
if (if_nametoindex(pt->tx_dev))
pt->tx_vdev_stream_type = IFACE;

View file

@ -193,7 +193,7 @@ proc_info_preparse_args(int argc, char **argv)
proc_info_usage(prgname);
return -1;
}
snprintf(host_id, sizeof(host_id), "%s", argv[i+1]);
strlcpy(host_id, argv[i + 1], sizeof(host_id));
}
}

View file

@ -226,9 +226,8 @@ parse_args(int argc, char **argv, struct test_params *tp)
TEST_ASSERT(strlen(optarg) > 0,
"Config file name is null");
snprintf(tp->test_vector_filename,
sizeof(tp->test_vector_filename),
"%s", optarg);
strlcpy(tp->test_vector_filename, optarg,
sizeof(tp->test_vector_filename));
break;
case 'l':
TEST_ASSERT(strlen(optarg) > 0,

View file

@ -118,8 +118,7 @@ test_parse_etheraddr_invalid_param(void)
/* try null result */
/* copy string to buffer */
snprintf(buf, sizeof(buf), "%s",
ether_addr_valid_strs[0].str);
strlcpy(buf, ether_addr_valid_strs[0].str, sizeof(buf));
ret = cmdline_parse_etheraddr(NULL, buf, NULL, 0);
if (ret == -1) {

View file

@ -318,8 +318,7 @@ test_parse_num_invalid_param(void)
token.num_data.type = UINT32;
/* copy string to buffer */
snprintf(buf, sizeof(buf), "%s",
num_valid_positive_strs[0].str);
strlcpy(buf, num_valid_positive_strs[0].str, sizeof(buf));
/* try all null */
ret = cmdline_parse_num(NULL, NULL, NULL, 0);

View file

@ -767,7 +767,7 @@ test_deflate_comp_decomp(const struct interim_data_params *int_data,
for (i = 0; i < num_bufs; i++) {
data_size = strlen(test_bufs[i]) + 1;
buf_ptr = rte_pktmbuf_append(uncomp_bufs[i], data_size);
snprintf(buf_ptr, data_size, "%s", test_bufs[i]);
strlcpy(buf_ptr, test_bufs[i], data_size);
}
}

View file

@ -58,7 +58,7 @@ get_hugepage_path(char * src, int src_len, char * dst, int dst_len)
return 0;
if (strncmp(tokens[2], "hugetlbfs", sizeof("hugetlbfs")) == 0) {
snprintf(dst, dst_len, "%s", tokens[1]);
strlcpy(dst, tokens[1], dst_len);
return 1;
}
return 0;

View file

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

View file

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

View file

@ -493,27 +493,27 @@ arp_op_name(uint16_t arp_op, char *buf, size_t buf_len)
{
switch (arp_op) {
case ARP_OP_REQUEST:
snprintf(buf, buf_len, "%s", "ARP Request");
strlcpy(buf, "ARP Request", buf_len);
return;
case ARP_OP_REPLY:
snprintf(buf, buf_len, "%s", "ARP Reply");
strlcpy(buf, "ARP Reply", buf_len);
return;
case ARP_OP_REVREQUEST:
snprintf(buf, buf_len, "%s", "Reverse ARP Request");
strlcpy(buf, "Reverse ARP Request", buf_len);
return;
case ARP_OP_REVREPLY:
snprintf(buf, buf_len, "%s", "Reverse ARP Reply");
strlcpy(buf, "Reverse ARP Reply", buf_len);
return;
case ARP_OP_INVREQUEST:
snprintf(buf, buf_len, "%s", "Peer Identify Request");
strlcpy(buf, "Peer Identify Request", buf_len);
return;
case ARP_OP_INVREPLY:
snprintf(buf, buf_len, "%s", "Peer Identify Reply");
strlcpy(buf, "Peer Identify Reply", buf_len);
return;
default:
break;
}
snprintf(buf, buf_len, "%s", "Unknown");
strlcpy(buf, "Unknown", buf_len);
return;
}
#endif

View file

@ -1334,10 +1334,9 @@ dpaa2_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",
dpaa2_xstats_strings[i].name);
strlcpy(xstats_names[i].name,
dpaa2_xstats_strings[i].name,
sizeof(xstats_names[i].name));
return stat_cnt;
}

View file

@ -102,7 +102,7 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline)
ERROR("Command line allocation failed");
return -ENOMEM;
}
snprintf(sdev->cmdline, len, "%s", cmdline);
strlcpy(sdev->cmdline, cmdline, len);
/* Replace all commas in the command line by spaces */
for (i = 0; i < len; i++)
if (sdev->cmdline[i] == ',')

View file

@ -3324,17 +3324,17 @@ static int i40e_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
/* Get stats from i40e_eth_stats struct */
for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s", rte_i40e_stats_strings[i].name);
strlcpy(xstats_names[count].name,
rte_i40e_stats_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}
/* Get individiual stats from i40e_hw_port struct */
for (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) {
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s", rte_i40e_hw_port_strings[i].name);
strlcpy(xstats_names[count].name,
rte_i40e_hw_port_strings[i].name,
sizeof(xstats_names[count].name));
count++;
}

View file

@ -1084,8 +1084,8 @@ eth_from_pcaps_common(struct rte_vdev_device *vdev,
struct devargs_queue *queue = &rx_queues->queue[i];
pp->rx_pcap[i] = queue->pcap;
snprintf(rx->name, sizeof(rx->name), "%s", queue->name);
snprintf(rx->type, sizeof(rx->type), "%s", queue->type);
strlcpy(rx->name, queue->name, sizeof(rx->name));
strlcpy(rx->type, queue->type, sizeof(rx->type));
}
for (i = 0; i < nb_tx_queues; i++) {
@ -1094,8 +1094,8 @@ eth_from_pcaps_common(struct rte_vdev_device *vdev,
pp->tx_dumper[i] = queue->dumper;
pp->tx_pcap[i] = queue->pcap;
snprintf(tx->name, sizeof(tx->name), "%s", queue->name);
snprintf(tx->type, sizeof(tx->type), "%s", queue->type);
strlcpy(tx->name, queue->name, sizeof(tx->name));
strlcpy(tx->type, queue->type, sizeof(tx->type));
}
return 0;

View file

@ -497,7 +497,8 @@ static int parse_kvlist (const char *key __rte_unused, const char *value, void *
goto out;
}
snprintf(info->list[info->count].name, sizeof(info->list[info->count].name), "%s", name);
strlcpy(info->list[info->count].name, name,
sizeof(info->list[info->count].name));
info->count++;

View file

@ -91,7 +91,7 @@ softnic_tap_create(struct pmd_internals *p,
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI; /* No packet information */
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", name);
strlcpy(ifr.ifr_name, name, IFNAMSIZ);
status = ioctl(fd, TUNSETIFF, (void *)&ifr);
if (status < 0) {

View file

@ -760,9 +760,9 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request,
*/
apply:
if (remote)
snprintf(ifr->ifr_name, IFNAMSIZ, "%s", pmd->remote_iface);
strlcpy(ifr->ifr_name, pmd->remote_iface, IFNAMSIZ);
else if (mode == LOCAL_ONLY || mode == LOCAL_AND_REMOTE)
snprintf(ifr->ifr_name, IFNAMSIZ, "%s", pmd->name);
strlcpy(ifr->ifr_name, pmd->name, IFNAMSIZ);
switch (request) {
case SIOCSIFFLAGS:
/* fetch current flags to leave other flags untouched */
@ -1714,7 +1714,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
pmd = dev->data->dev_private;
dev->process_private = process_private;
pmd->dev = dev;
snprintf(pmd->name, sizeof(pmd->name), "%s", tap_name);
strlcpy(pmd->name, tap_name, sizeof(pmd->name));
pmd->type = type;
pmd->ioctl_sock = socket(AF_INET, SOCK_DGRAM, 0);
@ -1823,8 +1823,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
pmd->name, remote_iface);
goto error_remote;
}
snprintf(pmd->remote_iface, RTE_ETH_NAME_MAX_LEN,
"%s", remote_iface);
strlcpy(pmd->remote_iface, remote_iface, RTE_ETH_NAME_MAX_LEN);
/* Save state of remote device */
tap_ioctl(pmd, SIOCGIFFLAGS, &pmd->remote_initial_flags, 0, REMOTE_ONLY);

View file

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

View file

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

View file

@ -176,7 +176,7 @@ static int tap_create(char *name)
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
if (name && *name)
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", name);
strlcpy(ifr.ifr_name, name, IFNAMSIZ);
ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
if (ret < 0) {
@ -185,7 +185,7 @@ static int tap_create(char *name)
}
if (name)
snprintf(name, IFNAMSIZ, "%s", ifr.ifr_name);
strlcpy(name, ifr.ifr_name, IFNAMSIZ);
return fd;
}

View file

@ -126,7 +126,7 @@ kni_create(const char *name, struct kni_params *params)
rte_eth_dev_info_get(link->port_id, &dev_info);
memset(&kni_conf, 0, sizeof(kni_conf));
snprintf(kni_conf.name, RTE_KNI_NAMESIZE, "%s", name);
strlcpy(kni_conf.name, name, RTE_KNI_NAMESIZE);
kni_conf.force_bind = params->force_bind;
kni_conf.core_id = params->thread_id;
kni_conf.group_id = link->port_id;

View file

@ -75,7 +75,7 @@ tap_create(const char *name)
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI; /* No packet information */
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", name);
strlcpy(ifr.ifr_name, name, IFNAMSIZ);
status = ioctl(fd, TUNSETIFF, (void *) &ifr);
if (status < 0) {

View file

@ -1384,7 +1384,7 @@ parse_ep_config(const char *q_arg)
ep_med_edpi = EMPTY_POLL_MED_THRESHOLD;
ep_hgh_edpi = EMPTY_POLL_MED_THRESHOLD;
snprintf(s, sizeof(s), "%s", p);
strlcpy(s, p, sizeof(s));
num_arg = rte_strsplit(s, sizeof(s), str_fld, 3, ',');

View file

@ -48,7 +48,7 @@ static void cmd_send_parsed(void *parsed_result,
if (rte_mempool_get(message_pool, &msg) < 0)
rte_panic("Failed to get message buffer\n");
snprintf((char *)msg, STR_TOKEN_SIZE, "%s", res->message);
strlcpy((char *)msg, res->message, STR_TOKEN_SIZE);
if (rte_ring_enqueue(send_ring, msg) < 0) {
printf("Failed to send message - message discarded\n");
rte_mempool_put(message_pool, msg);

View file

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

View file

@ -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 */

View file

@ -191,7 +191,7 @@ us_vhost_parse_basename(const char *q_arg)
if (strlen(q_arg) >= MAX_BASENAME_SZ)
return -1;
else
snprintf((char *)&dev_basename, MAX_BASENAME_SZ, "%s", q_arg);
strlcpy((char *)&dev_basename, q_arg, MAX_BASENAME_SZ);
return 0;
}

View file

@ -366,7 +366,7 @@ us_vhost_parse_socket_path(const char *q_arg)
return -1;
}
snprintf(socket_files + nb_sockets * PATH_MAX, PATH_MAX, "%s", q_arg);
strlcpy(socket_files + nb_sockets * PATH_MAX, q_arg, PATH_MAX);
nb_sockets++;
return 0;

View file

@ -234,8 +234,8 @@ vhost_bdev_scsi_inquiry_command(struct vhost_block_dev *bdev,
desig->reserved0 = 0;
desig->piv = 1;
desig->reserved1 = 0;
desig->len = snprintf((char *)desig->desig,
255, "%s", bdev->name);
desig->len = strlcpy((char *)desig->desig, bdev->name,
255);
len += sizeof(struct scsi_desig_desc) + desig->len;
buf += sizeof(struct scsi_desig_desc) + desig->len;
@ -281,9 +281,8 @@ vhost_bdev_scsi_inquiry_command(struct vhost_block_dev *bdev,
sizeof(inqdata->t10_vendor_id));
/* PRODUCT IDENTIFICATION */
snprintf((char *)inqdata->product_id,
RTE_DIM(inqdata->product_id), "%s",
bdev->product_name);
strlcpy((char *)inqdata->product_id, bdev->product_name,
RTE_DIM(inqdata->product_id));
/* PRODUCT REVISION LEVEL */
strlcpy((char *)inqdata->product_rev, "0001",

View file

@ -69,7 +69,7 @@ cmdline_set_prompt(struct cmdline *cl, const char *prompt)
{
if (!cl || !prompt)
return;
snprintf(cl->prompt, sizeof(cl->prompt), "%s", prompt);
strlcpy(cl->prompt, prompt, sizeof(cl->prompt));
}
struct cmdline *

View file

@ -394,8 +394,9 @@ cmdline_complete(struct cmdline *cl, const char *buf, int *state,
if (!strncmp(partial_tok, tmpbuf,
partial_tok_len)) {
if (comp_len == -1) {
snprintf(comp_buf, sizeof(comp_buf),
"%s", tmpbuf + partial_tok_len);
strlcpy(comp_buf,
tmpbuf + partial_tok_len,
sizeof(comp_buf));
comp_len =
strnlen(tmpbuf + partial_tok_len,
sizeof(tmpbuf) - partial_tok_len);

View file

@ -340,7 +340,7 @@ cmdline_get_help_num(cmdline_parse_token_hdr_t *tk, char *dstbuf, unsigned int s
/* if (nd.type >= (sizeof(num_help)/sizeof(const char *))) */
/* return -1; */
ret = snprintf(dstbuf, size, "%s", num_help[nd.type]);
ret = strlcpy(dstbuf, num_help[nd.type], size);
if (ret < 0)
return -1;
dstbuf[size-1] = '\0';

View file

@ -698,8 +698,8 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id)
cryptodev->data = cryptodev_data;
snprintf(cryptodev->data->name, RTE_CRYPTODEV_NAME_MAX_LEN,
"%s", name);
strlcpy(cryptodev->data->name, name,
RTE_CRYPTODEV_NAME_MAX_LEN);
cryptodev->data->dev_id = dev_id;
cryptodev->data->socket_id = socket_id;

View file

@ -625,7 +625,7 @@ rte_distributor_create_v1705(const char *name,
}
d = mz->addr;
snprintf(d->name, sizeof(d->name), "%s", name);
strlcpy(d->name, name, sizeof(d->name));
d->num_workers = num_workers;
d->alg_type = alg_type;

View file

@ -386,7 +386,7 @@ rte_distributor_create_v20(const char *name,
}
d = mz->addr;
snprintf(d->name, sizeof(d->name), "%s", name);
strlcpy(d->name, name, sizeof(d->name));
d->num_workers = num_workers;
distributor_list = RTE_TAILQ_CAST(rte_distributor_tailq.head,

View file

@ -171,7 +171,7 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
return NULL;
}
snprintf(mz->name, sizeof(mz->name), "%s", name);
strlcpy(mz->name, name, sizeof(mz->name));
mz->iova = rte_malloc_virt2iova(mz_addr);
mz->addr = mz_addr;
mz->len = requested_len == 0 ?

View file

@ -80,7 +80,7 @@ rte_eal_tailq_create(const char *name)
mcfg = rte_eal_get_configuration()->mem_config;
head = &mcfg->tailq_head[rte_tailqs_count];
snprintf(head->name, sizeof(head->name) - 1, "%s", name);
strlcpy(head->name, name, sizeof(head->name) - 1);
TAILQ_INIT(&head->tailq_head);
rte_tailqs_count++;
}

View file

@ -2068,9 +2068,9 @@ rte_eth_basic_stats_get_names(struct rte_eth_dev *dev,
uint16_t num_q;
for (idx = 0; idx < RTE_NB_STATS; idx++) {
snprintf(xstats_names[cnt_used_entries].name,
sizeof(xstats_names[0].name),
"%s", rte_stats_strings[idx].name);
strlcpy(xstats_names[cnt_used_entries].name,
rte_stats_strings[idx].name,
sizeof(xstats_names[0].name));
cnt_used_entries++;
}
num_q = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);

View file

@ -381,7 +381,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
default_hash_func = (rte_hash_function)rte_hash_crc;
#endif
/* Setup hash context */
snprintf(h->name, sizeof(h->name), "%s", params->name);
strlcpy(h->name, params->name, sizeof(h->name));
h->entries = params->entries;
h->key_len = params->key_len;
h->key_entry_size = key_entry_size;

View file

@ -141,7 +141,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
#endif
/* Set up hash table context. */
snprintf(ht->name, sizeof(ht->name), "%s", params->name);
strlcpy(ht->name, params->name, sizeof(ht->name));
ht->entries = params->entries;
ht->entries_per_bucket = params->entries_per_bucket;
ht->used_entries = 0;

View file

@ -234,7 +234,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
goto kni_fail;
}
snprintf(kni->name, RTE_KNI_NAMESIZE, "%s", conf->name);
strlcpy(kni->name, conf->name, RTE_KNI_NAMESIZE);
if (ops)
memcpy(&kni->ops, ops, sizeof(struct rte_kni_ops));
@ -255,7 +255,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
memcpy(dev_info.mac_addr, conf->mac_addr, ETHER_ADDR_LEN);
snprintf(dev_info.name, RTE_KNI_NAMESIZE, "%s", conf->name);
strlcpy(dev_info.name, conf->name, RTE_KNI_NAMESIZE);
RTE_LOG(INFO, KNI, "pci: %02x:%02x:%02x \t %02x:%02x\n",
dev_info.bus, dev_info.devid, dev_info.function,
@ -400,7 +400,7 @@ rte_kni_release(struct rte_kni *kni)
if (te == NULL)
goto unlock;
snprintf(dev_info.name, sizeof(dev_info.name), "%s", kni->name);
strlcpy(dev_info.name, kni->name, sizeof(dev_info.name));
if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) {
RTE_LOG(ERR, KNI, "Fail to release kni device\n");
goto unlock;

View file

@ -205,7 +205,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
/* Save user arguments. */
lpm->max_rules = max_rules;
snprintf(lpm->name, sizeof(lpm->name), "%s", name);
strlcpy(lpm->name, name, sizeof(lpm->name));
te->data = lpm;
@ -308,7 +308,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
/* Save user arguments. */
lpm->max_rules = config->max_rules;
lpm->number_tbl8s = config->number_tbl8s;
snprintf(lpm->name, sizeof(lpm->name), "%s", name);
strlcpy(lpm->name, name, sizeof(lpm->name));
te->data = lpm;

View file

@ -352,7 +352,7 @@ rte_lpm6_create(const char *name, int socket_id,
/* Save user arguments. */
lpm->max_rules = config->max_rules;
lpm->number_tbl8s = config->number_tbl8s;
snprintf(lpm->name, sizeof(lpm->name), "%s", name);
strlcpy(lpm->name, name, sizeof(lpm->name));
lpm->rules_tbl = rules_tbl;
lpm->tbl8_pool = tbl8_pool;
lpm->tbl8_hdrs = tbl8_hdrs;

View file

@ -864,7 +864,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
/* init the mempool structure */
mp = mz->addr;
memset(mp, 0, MEMPOOL_HEADER_SIZE(mp, cache_size));
ret = snprintf(mp->name, sizeof(mp->name), "%s", name);
ret = strlcpy(mp->name, name, sizeof(mp->name));
if (ret < 0 || ret >= (int)sizeof(mp->name)) {
rte_errno = ENAMETOOLONG;
goto exit_unlock;

View file

@ -501,15 +501,15 @@ pdump_prepare_client_request(char *device, uint16_t queue,
req->flags = flags;
req->op = operation;
if ((operation & ENABLE) != 0) {
snprintf(req->data.en_v1.device,
sizeof(req->data.en_v1.device), "%s", device);
strlcpy(req->data.en_v1.device, device,
sizeof(req->data.en_v1.device));
req->data.en_v1.queue = queue;
req->data.en_v1.ring = ring;
req->data.en_v1.mp = mp;
req->data.en_v1.filter = filter;
} else {
snprintf(req->data.dis_v1.device,
sizeof(req->data.dis_v1.device), "%s", device);
strlcpy(req->data.dis_v1.device, device,
sizeof(req->data.dis_v1.device));
req->data.dis_v1.queue = queue;
req->data.dis_v1.ring = NULL;
req->data.dis_v1.mp = NULL;

View file

@ -214,7 +214,7 @@ rte_pipeline_create(struct rte_pipeline_params *params)
}
/* Save input parameters */
snprintf(p->name, RTE_PIPELINE_MAX_NAME_SZ, "%s", params->name);
strlcpy(p->name, params->name, RTE_PIPELINE_MAX_NAME_SZ);
p->socket_id = params->socket_id;
p->offset_port_id = params->offset_port_id;

View file

@ -78,7 +78,7 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,
/* init the ring structure */
memset(r, 0, sizeof(*r));
ret = snprintf(r->name, sizeof(r->name), "%s", name);
ret = strlcpy(r->name, name, sizeof(r->name));
if (ret < 0 || ret >= (int)sizeof(r->name))
return -ENAMETOOLONG;
r->flags = flags;