From: Breno Leitao Date: Mon, 17 Feb 2025 15:48:13 +0000 (-0800) Subject: net: Remove redundant variable declaration in __dev_change_flags() X-Git-Tag: v6.15-rc1~160^2~283 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f02c48f8f623eedc3c0a26a64c7ef155c35bfb9;p=thirdparty%2Flinux.git 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 Reviewed-by: Mateusz Polchlopek Reviewed-by: Kalesh AP Reviewed-by: Nicolas Dichtel Reviewed-by: Andrew Lunn Link: https://patch.msgid.link/20250217-old_flags-v2-1-4cda3b43a35f@debian.org Signed-off-by: Jakub Kicinski --- diff --git a/net/core/dev.c b/net/core/dev.c index bcb266ab29126..ebc000b568283 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9182,7 +9182,7 @@ int __dev_change_flags(struct net_device *dev, unsigned int flags, if ((flags ^ dev->gflags) & IFF_PROMISC) { int inc = (flags & IFF_PROMISC) ? 1 : -1; - unsigned int old_flags = dev->flags; + old_flags = dev->flags; dev->gflags ^= IFF_PROMISC;