From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Wiles, Keith" Subject: Re: [PATCH v2] ethdev: report error on name truncation Date: Sun, 13 Jan 2019 19:28:49 +0000 Message-ID: <0D9DB313-B5F8-4AD0-871F-CEECC49B4359@intel.com> References: <20190107143951.30076-1-ndabilpuram@marvell.com> <20190113153749.3540-1-ndabilpuram@marvell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: Thomas Monjalon , "Yigit, Ferruh" , Andrew Rybchenko , "dev@dpdk.org" , Jerin Jacob Kollanukkaran To: Nithin Kumar Dabilpuram Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id EEF581B477 for ; Sun, 13 Jan 2019 20:28:51 +0100 (CET) In-Reply-To: <20190113153749.3540-1-ndabilpuram@marvell.com> Content-Language: en-US Content-ID: <5D5C9606D94B1E49894BD58C48F3C8EE@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > On Jan 13, 2019, at 9:38 AM, Nithin Kumar Dabilpuram wrote: >=20 > 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. >=20 > Signed-off-by: Nithin Dabilpuram > --- >=20 > v2: > Fix issue caused by rebase and also fix log message >=20 > lib/librte_ethdev/rte_ethdev.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.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; >=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; > + } I we are already returning an error here should the RTE_LOG be DEBUG and no= t ERR. Of course this does mean we would have to check return codes :-) >=20 > mz =3D rte_memzone_lookup(z_name); > if (mz) > --=20 > 2.8.4 >=20 Regards, Keith