mirror of
https://github.com/apache/nuttx.git
synced 2026-05-18 00:08:42 +08:00
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:
committed by
Petro Karashchenko
parent
f7dec2c250
commit
c66ba22812
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user