]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: Remove shadow variable in netdev_run_todo()
authorBreno Leitao <leitao@debian.org>
Fri, 21 Feb 2025 17:51:27 +0000 (09:51 -0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 24 Feb 2025 22:34:54 +0000 (14:34 -0800)
Fix a shadow variable warning in net/core/dev.c when compiled with
CONFIG_LOCKDEP enabled. The warning occurs because 'dev' is redeclared
inside the while loop, shadowing the outer scope declaration.

net/core/dev.c:11211:22: warning: declaration shadows a local variable [-Wshadow]
struct net_device *dev = list_first_entry(&unlink_list,

net/core/dev.c:11202:21: note: previous declaration is here
struct net_device *dev, *tmp;

Remove the redundant declaration since the variable is already defined
in the outer scope and will be overwritten in the subsequent
list_for_each_entry_safe() loop anyway.

Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20250221-netcons_fix_shadow-v1-1-dee20c8658dd@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/dev.c

index 8c7ee7ada6a3e060d7d6e9574e815ab93ca2e0d3..3f525278a8718b3de8913463d4c35125086ae8aa 100644 (file)
@@ -11209,9 +11209,8 @@ void netdev_run_todo(void)
        list_replace_init(&net_unlink_list, &unlink_list);
 
        while (!list_empty(&unlink_list)) {
-               struct net_device *dev = list_first_entry(&unlink_list,
-                                                         struct net_device,
-                                                         unlink_list);
+               dev = list_first_entry(&unlink_list, struct net_device,
+                                      unlink_list);
                list_del_init(&dev->unlink_list);
                dev->nested_level = dev->lower_level - 1;
        }