From: Nithin Dabilpuram Date: Thu, 17 Jan 2019 14:13:54 +0000 (+0000) Subject: ethdev: report error on ring name truncation X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e1e1c08a53faecd6504a063b08dc5616135a773d;p=dpdk.git ethdev: report error on ring name truncation 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 Acked-by: Thomas Monjalon --- diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 9d5107dce3..0d192a24b2 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3588,9 +3588,15 @@ 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, "ring name too long\n"); + rte_errno = ENAMETOOLONG; + return NULL; + } mz = rte_memzone_lookup(z_name); if (mz)