[dpdk-dev] [PATCH v2] ethdev: report error on name truncation
Nithin Kumar Dabilpuram
ndabilpuram at marvell.com
Sun Jan 13 16:38:15 CET 2019
Currently this api doesn't report error if name is
truncated and so user is not sure about uniqueness
of name. This change reports error to help user.
Signed-off-by: Nithin Dabilpuram <ndabilpuram at marvell.com>
---
v2:
Fix issue caused by rebase and also fix log message
lib/librte_ethdev/rte_ethdev.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 9d5107d..47d4f4a 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -3588,9 +3588,16 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
{
char z_name[RTE_MEMZONE_NAMESIZE];
const struct rte_memzone *mz;
+ int rc;
- snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s",
- dev->data->port_id, queue_id, ring_name);
+ rc = snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s",
+ dev->data->port_id, queue_id, ring_name);
+
+ if (rc >= RTE_MEMZONE_NAMESIZE) {
+ RTE_ETHDEV_LOG(ERR, "truncated name");
+ rte_errno = ENAMETOOLONG;
+ return NULL;
+ }
mz = rte_memzone_lookup(z_name);
if (mz)
--
2.8.4
More information about the dev
mailing list