Re: [PATCH net-next v2] net: Remove redundant variable declaration in __dev_change_flags()
From: Kalesh Anakkur Purayil
Date: Mon Feb 17 2025 - 21:55:45 EST
On Mon, Feb 17, 2025 at 9:21 PM Breno Leitao <leitao@xxxxxxxxxx> wrote:
>
> 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 <leitao@xxxxxxxxxx>
> Reviewed-by: Mateusz Polchlopek <mateusz.polchlopek@xxxxxxxxx>
LGTM,
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@xxxxxxxxxxxx>
--
Regards,
Kalesh AP
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature