Skip to content

Commit 8f02c48

Browse files
leitaokuba-moo
authored andcommitted
net: Remove redundant variable declaration in __dev_change_flags()
The old_flags variable is declared twice in __dev_change_flags(), causing a shadow variable warning. This patch fixes the issue by removing the redundant declaration, reusing the existing old_flags variable instead. net/core/dev.c:9225:16: warning: declaration shadows a local variable [-Wshadow] 9225 | unsigned int old_flags = dev->flags; | ^ net/core/dev.c:9185:15: note: previous declaration is here 9185 | unsigned int old_flags = dev->flags; | ^ 1 warning generated. Remove the redundant inner declaration and reuse the existing old_flags variable since its value is not needed outside the if block, and it is safe to reuse the variable. This eliminates the warning while maintaining the same functionality. Signed-off-by: Breno Leitao <[email protected]> Reviewed-by: Mateusz Polchlopek <[email protected]> Reviewed-by: Kalesh AP <[email protected]> Reviewed-by: Nicolas Dichtel <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f29e414 commit 8f02c48

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/core/dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9182,7 +9182,7 @@ int __dev_change_flags(struct net_device *dev, unsigned int flags,
91829182

91839183
if ((flags ^ dev->gflags) & IFF_PROMISC) {
91849184
int inc = (flags & IFF_PROMISC) ? 1 : -1;
9185-
unsigned int old_flags = dev->flags;
9185+
old_flags = dev->flags;
91869186

91879187
dev->gflags ^= IFF_PROMISC;
91889188

0 commit comments

Comments
 (0)