[dpdk-dev] [PATCH 3/4] ethdev: count devices consistently

Thomas Monjalon thomas.monjalon at 6wind.com
Thu Mar 30 21:26:12 CEST 2017


2017-03-03 16:40, Gaetan Rivet:
> Make the rte_eth_dev_count() return the correct number of devices even
> after some are detached by the hotplug API.

Please explain what is the correct number,
or that the wrong number was a max id.

> This change does not affect existing applications that do not use
> hotplug API calls. Those that do are already aware that port IDs are not
> necessarily contiguous.
[...]
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> -#define RTE_ETH_FOREACH_DEV(p)			\
> -	for (p = rte_eth_find_next(0);		\
> -	     p < RTE_MAX_ETHPORTS;		\
> +#define RTE_ETH_FOREACH_DEV(p)					\
> +	for (p = rte_eth_find_next(0);				\
> +	     (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS;	\
>  	     p = rte_eth_find_next(p + 1))

This macro was introduced in previous patch.
Why adding the cast here?


More information about the dev mailing list