[v3] ethdev: report error on name truncation
Checks
Commit Message
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@marvell.com>
---
v3:
Change log message
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(-)
Comments
17/01/2019 15:13, Nithin Kumar Dabilpuram:
> 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@marvell.com>
> ---
> + 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;
> + }
Usually we don't insert a blank line before a test of a return value.
It's really a nitpick, so Ferruh, it's up to you to keep it or not when applying.
Acked-by: Thomas Monjalon <thomas@monjalon.net>
On 1/17/2019 3:38 PM, Thomas Monjalon wrote:
> 17/01/2019 15:13, Nithin Kumar Dabilpuram:
>> 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@marvell.com>
>> ---
>> + 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;
>> + }
>
> Usually we don't insert a blank line before a test of a return value.
> It's really a nitpick, so Ferruh, it's up to you to keep it or not when applying.
>
> Acked-by: Thomas Monjalon <thomas@monjalon.net>
>
Applied to dpdk-next-net/master, thanks.
(Blank line removed while merging)
@@ -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, "ring name too long\n");
+ rte_errno = ENAMETOOLONG;
+ return NULL;
+ }
mz = rte_memzone_lookup(z_name);
if (mz)