* Copyright(c) 2010-2014 Intel Corporation
*/
+#include <rte_string_fns.h>
#include <rte_acl.h>
#include <getopt.h>
#include <string.h>
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
#include <inttypes.h>
#include <getopt.h>
+#include <rte_string_fns.h>
#include <rte_common.h>
#include <rte_eventdev.h>
#include <rte_lcore.h>
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;
}
#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>
(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;
(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;
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;
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;
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
* Copyright(c) 2010-2014 Intel Corporation
*/
+#include <rte_string_fns.h>
#include <rte_hexdump.h>
#include "test_table.h"
#include "test_table_acl.h"
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]);
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]);
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);
/* 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);
/* 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);
*/
#include <of.h>
+#include <rte_string_fns.h>
#include <rte_dpaa_logs.h>
static int alive;
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;
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);
#include <sys/io.h>
#endif
+#include <rte_string_fns.h>
#include <rte_log.h>
#include <rte_pci.h>
#include <rte_bus_pci.h>
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;
#include <string.h>
+#include <rte_string_fns.h>
#include <rte_common.h>
#include <rte_malloc.h>
#include <rte_cryptodev_pmd.h>
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;
* 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>
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,
/* 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>
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) {
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;
#include <stdint.h>
#include <stdio.h>
+#include <rte_string_fns.h>
#include <rte_branch_prediction.h>
#include <rte_debug.h>
#include <rte_lcore.h>
/* 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;
* All rights reserved.
*/
+#include <rte_string_fns.h>
#include <rte_mbuf.h>
#include <rte_ethdev_driver.h>
#include <rte_ethdev_vdev.h>
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);
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;
#include <locale.h>
#include <unistd.h>
+#include <rte_string_fns.h>
#include <rte_ethdev_driver.h>
#include <rte_malloc.h>
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;
#include <locale.h>
#include <unistd.h>
+#include <rte_string_fns.h>
#include <rte_eal.h>
#include <rte_ethdev_driver.h>
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;
* Copyright(c) 2018 Aquantia Corporation
*/
+#include <rte_string_fns.h>
#include <rte_ethdev_pci.h>
#include "atl_ethdev.h"
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;
}
#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>
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;
}
#include <inttypes.h>
+#include <rte_string_fns.h>
#include <rte_byteorder.h>
#include "bnxt.h"
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++;
}
#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>
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;
}
#include <stdint.h>
#include <stdarg.h>
+#include <rte_string_fns.h>
#include <rte_common.h>
#include <rte_interrupts.h>
#include <rte_byteorder.h>
/* 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;
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;
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;
}
* 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>
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) |
* Copyright 2017 Mellanox Technologies, Ltd
*/
+#include <rte_string_fns.h>
#include <rte_malloc.h>
#include "failsafe_private.h"
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"
* Copyright(c) 2010-2017 Intel Corporation
*/
+#include <rte_string_fns.h>
#include <rte_malloc.h>
#include <rte_tailq.h>
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];
}
* Copyright(c) 2018 Intel Corporation
*/
+#include <rte_string_fns.h>
#include <rte_ethdev_pci.h>
#include <stdio.h>
/* 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++;
}
#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>
/* 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++;
}
/* 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++;
}
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;
}
#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>
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 =
* Copyright(c) 2017 Cavium, Inc
*/
+#include <rte_string_fns.h>
#include <rte_ethdev_driver.h>
#include <rte_ethdev_pci.h>
#include <rte_cycles.h>
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);
* All rights reserved.
*/
+#include <rte_string_fns.h>
#include <rte_ethdev_driver.h>
#include <rte_kvargs.h>
#include <rte_bus_vdev.h>
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;
* All rights reserved.
*/
+#include <rte_string_fns.h>
#include <rte_ethdev_driver.h>
#include <rte_kvargs.h>
#include <rte_log.h>
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;
}
*/
#include "qede_ethdev.h"
+#include <rte_string_fns.h>
#include <rte_alarm.h>
#include <rte_version.h>
#include <rte_kvargs.h>
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++;
}
}
#include <string.h>
#include <errno.h>
+#include <rte_string_fns.h>
#include <rte_fbarray.h>
#include <rte_eal_memconfig.h>
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;
#include <sys/types.h>
#include <sys/stat.h>
+#include <rte_string_fns.h>
#include <rte_eal_memconfig.h>
#include "vhost.h"
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 */
#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>
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);
#include <fcntl.h>
#include <unistd.h>
+#include <rte_string_fns.h>
#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_common.h>
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;
}
#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>
!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, ".");
"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;
#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>
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")) {
}
} 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")) {
}
} 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")) {
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;
(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")) {
* Copyright(c) 2010-2014 Intel Corporation
*/
+#include <rte_string_fns.h>
#include <rte_acl.h>
#include "acl.h"
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;
#include <string.h>
#include <stdbool.h>
+#include <rte_string_fns.h>
#include <rte_compat.h>
#include <rte_common.h>
#include <rte_errno.h>
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;
#include <string.h>
#include <ctype.h>
#include <errno.h>
+#include <rte_string_fns.h>
#include <rte_common.h>
#include "rte_cfgfile.h"
struct rte_cfgfile_entry *curr_entry =
§ion->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;
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++;
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");
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;
}
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
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;
#include <stdio.h>
#include <inttypes.h>
+#include <rte_string_fns.h>
#include <rte_malloc.h>
#include <rte_eal.h>
#include <rte_memzone.h>
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;
* Copyright(c) 2017-2018 Intel Corporation
*/
+#include <rte_string_fns.h>
#include <rte_malloc.h>
#include <rte_kvargs.h>
#include <rte_eal.h>
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;
* Copyright(c) 2017 Intel Corporation
*/
+#include <rte_string_fns.h>
#include <rte_malloc.h>
#include "rte_cryptodev_pmd.h"
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;
#include <sys/stat.h>
#include <dirent.h>
+#include <rte_string_fns.h>
#include <rte_eal.h>
#include <rte_log.h>
#include <rte_lcore.h>
}
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);
#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>
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",
#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>
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;
* 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"
}
/* 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;
#include <stdlib.h>
#include <errno.h>
+#include <rte_string_fns.h>
#include <rte_errno.h>
#include <rte_common.h>
#include <rte_eal.h>
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;
#include <stdbool.h>
#include <math.h>
+#include <rte_string_fns.h>
#include <rte_mbuf.h>
#include <rte_log.h>
#include <rte_cycles.h>
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;
}
#include <string.h>
+#include <rte_string_fns.h>
#include <rte_eal.h>
#include <rte_eal_memconfig.h>
#include <rte_memory.h>
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;
#include <stdio.h>
#include <string.h>
+#include <rte_string_fns.h>
#include <rte_mempool.h>
#include <rte_errno.h>
#include <rte_dev.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;
#include <signal.h>
#include <limits.h>
+#include <rte_string_fns.h>
#include <rte_memcpy.h>
#include <rte_atomic.h>
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);
#include <errno.h>
#include <inttypes.h>
+#include <rte_string_fns.h>
#include <rte_memcpy.h>
#include <rte_atomic.h>
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);
#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>
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++;
#include <inttypes.h>
#include <string.h>
+#include <rte_string_fns.h>
#include <rte_log.h>
#include <rte_mbuf.h>
#include <rte_eal_memconfig.h>
}
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;
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);
}
#include <string.h>
+#include <rte_string_fns.h>
#include <rte_atomic.h>
#include <rte_eal.h>
#include <rte_eal_memconfig.h>
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);