On Thu, Mar 30, 2017 at 09:26:12PM +0200, Thomas Monjalon wrote:
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.
will do.
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?
In the function rte_eth_dev_get_port_by_name(), the iterator is an int.
When I introduced the use of the iterator there, I then realized that it
would be better to allow users to use signed ints as well, to avoid
unnecessary edits on their part.
In retrospective, I agree that it would have been better in the previous
patch.
--
Gaëtan Rivet
6WIND