From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nithin Kumar Dabilpuram Subject: [PATCH v2] ethdev: report error on name truncation Date: Sun, 13 Jan 2019 15:38:15 +0000 Message-ID: <20190113153749.3540-1-ndabilpuram@marvell.com> References: <20190107143951.30076-1-ndabilpuram@marvell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" , Jerin Jacob Kollanukkaran , Nithin Kumar Dabilpuram To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Return-path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 9A68B1B44B for ; Sun, 13 Jan 2019 16:38:19 +0100 (CET) In-Reply-To: <20190107143951.30076-1-ndabilpuram@marvell.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 *d= ev, const char *ring_name, { char z_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; + int rc; =20 - snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", - dev->data->port_id, queue_id, ring_name); + rc =3D snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", + dev->data->port_id, queue_id, ring_name); + + if (rc >=3D RTE_MEMZONE_NAMESIZE) { + RTE_ETHDEV_LOG(ERR, "truncated name"); + rte_errno =3D ENAMETOOLONG; + return NULL; + } =20 mz =3D rte_memzone_lookup(z_name); if (mz) --=20 2.8.4