Fix Error: netdev/netdev_findbyindex.c:59:7: error: variable 'i' set but not used

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-11-22 07:33:00 +08:00 committed by Petro Karashchenko
parent f7dec2c250
commit c66ba22812
1 changed files with 5 additions and 4 deletions

View File

@ -56,8 +56,6 @@
FAR struct net_driver_s *netdev_findbyindex(int ifindex)
{
FAR struct net_driver_s *dev;
int i;
#ifdef CONFIG_NETDEV_IFINDEX
/* The bit index is the interface index minus one. Zero is reserved in
* POSIX to mean no interface index.
@ -68,6 +66,9 @@ FAR struct net_driver_s *netdev_findbyindex(int ifindex)
{
return NULL;
}
#else
int i = 0;
#endif
net_lock();
@ -84,7 +85,7 @@ FAR struct net_driver_s *netdev_findbyindex(int ifindex)
}
#endif
for (i = 0, dev = g_netdevices; dev; i++, dev = dev->flink)
for (dev = g_netdevices; dev; dev = dev->flink)
{
#ifdef CONFIG_NETDEV_IFINDEX
/* Check if the index matches the index assigned when the device was
@ -99,7 +100,7 @@ FAR struct net_driver_s *netdev_findbyindex(int ifindex)
* caller keeps the network locked).
*/
if (i == (ifindex - 1))
if (++i == ifindex)
#endif
{
net_unlock();