Skip to content

Commit

Permalink
net: mpls: Fix GCC 12 warning
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
victor-erminpour authored and davem330 committed Feb 10, 2022
1 parent 9ccc6e0 commit c4416f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/mpls/af_mpls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit c4416f5

Please sign in to comment.