> On Jan 13, 2019, at 9:38 AM, Nithin Kumar Dabilpuram 
> <ndabilpu...@marvell.com> wrote:
> 
> 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 <ndabilpu...@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;
> +     }

I we are already returning an error here should the RTE_LOG be DEBUG and not 
ERR. Of course this does mean we would have to check return codes :-)
> 
>       mz = rte_memzone_lookup(z_name);
>       if (mz)
> -- 
> 2.8.4
> 

Regards,
Keith

Reply via email to