You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/11/23 06:27:55 UTC
[incubator-nuttx] 01/03: Fix Error: netdev/netdev_findbyindex.c:59:7: error: variable 'i' set but not used
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit c66ba228129807eb3d1682fa45a2a513ec70c0bd
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Nov 22 07:33:00 2022 +0800
Fix Error: netdev/netdev_findbyindex.c:59:7: error: variable 'i' set but not used
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
net/netdev/netdev_findbyindex.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/netdev/netdev_findbyindex.c b/net/netdev/netdev_findbyindex.c
index 1fbef332f0..afed76fee2 100644
--- a/net/netdev/netdev_findbyindex.c
+++ b/net/netdev/netdev_findbyindex.c
@@ -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();