[dpdk-dev] [PATCH v2 08/15] devargs: use existing functions in rte_eal_devargs_parse()

Ferruh Yigit ferruh.yigit at intel.com
Mon Sep 4 18:24:23 CEST 2017


On 7/14/2017 10:12 PM, Jan Blunck wrote:
> This fixes the newly introduces rte_eal_devargs_parse() to make use of:
> - snprintf() instead of open coding a while() loop
> - rte_eal_parse_devargs_str() instead of duplicating parsing code
> - RTE_LOG() instead of direct output to stderr
> 
> Signed-off-by: Jan Blunck <jblunck at infradead.org>
> ---
>  lib/librte_eal/common/eal_common_devargs.c | 57 +++++++++++++++---------------
>  1 file changed, 28 insertions(+), 29 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
> index 205fabb95..b5273287e 100644
> --- a/lib/librte_eal/common/eal_common_devargs.c
> +++ b/lib/librte_eal/common/eal_common_devargs.c
> @@ -87,54 +87,53 @@ int
>  rte_eal_devargs_parse(const char *dev, struct rte_devargs *da)

here "const char *dev" is devarg_str, it can be something like:
"00:01.0,somekey=somevalue,keymore=valuemore"

Calling this "dev" is confusing I think, since you are touching to the
function does it make sense to rename this?

>  {
>  	struct rte_bus *bus = NULL;
> -	const char *devname;
> -	const size_t maxlen = sizeof(da->name);
> -	size_t i;
> +	char *devname = NULL, *drvargs = NULL;
> +	int ret;
>  
>  	if (dev == NULL || da == NULL)
>  		return -EINVAL;
>  	/* Retrieve eventual bus info */
>  	do {
> -		devname = dev;
>  		bus = rte_bus_find(bus, bus_name_cmp, dev);
>  		if (bus == NULL)
>  			break;
> -		devname = dev + strlen(bus->name) + 1;
> -		if (rte_bus_find_by_device_name(devname) == bus)
> +		dev += strlen(bus->name) + 1;

This deserves a comment I believe, what is done here?

> +		if (rte_bus_find_by_device_name(dev) == bus)
>  			break;
>  	} while (1);

<...>


More information about the dev mailing list