linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: mpls: Fix GCC 12 warning
@ 2022-02-10  0:28 Victor Erminpour
  2022-02-10 15:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Victor Erminpour @ 2022-02-10  0:28 UTC (permalink / raw)
  To: davem
  Cc: victor.erminpour, kuba, bpoirier, l4stpr0gr4m, jiapeng.chong,
	netdev, linux-kernel, trivial

When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move the variable outside the switch, which silences the warning:

./net/mpls/af_mpls.c:1624:21: error: statement will never be executed [-Werror=switch-unreachable]
  1624 |                 int err;
       |                     ^~~

Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
---
 net/mpls/af_mpls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 48f75a56f4ae..d6fdc5782d33 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -1607,6 +1607,7 @@ static int mpls_dev_notify(struct notifier_block *this, unsigned long event,
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 	struct mpls_dev *mdev;
 	unsigned int flags;
+	int err;
 
 	if (event == NETDEV_REGISTER) {
 		mdev = mpls_add_dev(dev);
@@ -1621,7 +1622,6 @@ static int mpls_dev_notify(struct notifier_block *this, unsigned long event,
 		return NOTIFY_OK;
 
 	switch (event) {
-		int err;
 
 	case NETDEV_DOWN:
 		err = mpls_ifdown(dev, event);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: mpls: Fix GCC 12 warning
  2022-02-10  0:28 [PATCH] net: mpls: Fix GCC 12 warning Victor Erminpour
@ 2022-02-10 15:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-10 15:40 UTC (permalink / raw)
  To: Victor Erminpour
  Cc: davem, kuba, bpoirier, l4stpr0gr4m, jiapeng.chong, netdev,
	linux-kernel, trivial

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed,  9 Feb 2022 16:28:38 -0800 you wrote:
> When building with automatic stack variable initialization, GCC 12
> complains about variables defined outside of switch case statements.
> Move the variable outside the switch, which silences the warning:
> 
> ./net/mpls/af_mpls.c:1624:21: error: statement will never be executed [-Werror=switch-unreachable]
>   1624 |                 int err;
>        |                     ^~~
> 
> [...]

Here is the summary with links:
  - net: mpls: Fix GCC 12 warning
    https://git.kernel.org/netdev/net/c/c4416f5c2eb3

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-10 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10  0:28 [PATCH] net: mpls: Fix GCC 12 warning Victor Erminpour
2022-02-10 15:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).