Skip to contentSkip to conversation

net: mana: remove unreachable dead code in mana_bpf()

PATCH Superseded Muhammad Falak R Wani 3 participants 4 messages Aug 24 – Aug 25

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: mana: remove unreachable dead code in mana_bpf()

mana_bpf() declares an uninitialized 'ret' and falls through to a trailing 'return ret;' after a switch statement whose every case (XDP_SETUP_PROG and default) already returns unconditionally. This statement is therefore unreachable dead code left over from an earlier refactor, and it would return an uninitialized value if it were ever reached.

Drop the unused variable and the unreachable return.

---
 drivers/net/ethernet/microsoft/mana/mana_bpf.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_bpf.c +0 -3
index 53308e139cbe9..70bb8c9dc3413 100644
@@ -253,7 +253,6 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
 int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf)
 {
 	struct netlink_ext_ack *extack = bpf->extack;
-	int ret;
 
 	switch (bpf->command) {
 	case XDP_SETUP_PROG:
@@ -262,6 +261,4 @@ int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf)
 	default:
 		return -EOPNOTSUPP;
 	}
-
-	return ret;
 }
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Muhammad Falak R Wani

mana_bpf() declares an uninitialized 'ret' and falls through to a trailing 'return ret;' after a switch statement whose every case (XDP_SETUP_PROG and default) already returns unconditionally. This statement is therefore unreachable dead code left over from an earlier refactor, and it would return an uninitialized value if it were ever reached.

Drop the unused variable and the unreachable return.

Fixes ed5356b53f07 ("net: mana: Add XDP support")
Quoted 26 lines
---
 drivers/net/ethernet/microsoft/mana/mana_bpf.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_bpf.c +0 -3
index 53308e139cbe9..70bb8c9dc3413 100644
@@ -253,7 +253,6 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
 int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf)
 {
 	struct netlink_ext_ack *extack = bpf->extack;
-	int ret;
 
 	switch (bpf->command) {
 	case XDP_SETUP_PROG:
@@ -262,6 +261,4 @@ int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf)
 	default:
 		return -EOPNOTSUPP;
 	}
-
-	return ret;
 }
Signature · 1 line
2.55.0
maintainer
#2 lore raw
Quoted 8 lines · Hamza Mahfooz
Quoted 7 lines · Muhammad Falak R Wani

mana_bpf() declares an uninitialized 'ret' and falls through to a trailing 'return ret;' after a switch statement whose every case (XDP_SETUP_PROG and default) already returns unconditionally. This statement is therefore unreachable dead code left over from an earlier refactor, and it would return an uninitialized value if it were ever reached.

Quoted 6 lines
Quoted 3 lines

Drop the unused variable and the unreachable return.

Fixes ed5356b53f07 ("net: mana: Add XDP support")

Please note that the current guidance is no fixes tag for net-next changes.

Also this specific change does not address any real issue, it's just code cleanup.

/P

maintainer
#3 lore raw
In reply to Muhammad Falak R Wani
Quoted 10 lines · Muhammad Falak R Wani

mana_bpf() declares an uninitialized 'ret' and falls through to a trailing 'return ret;' after a switch statement whose every case (XDP_SETUP_PROG and default) already returns unconditionally. This statement is therefore unreachable dead code left over from an earlier refactor, and it would return an uninitialized value if it were ever reached.

Drop the unused variable and the unreachable return.

## Form letter - net-next-closed

net-next pull request for v7.3 has already been merged, and therefore the net-next tree is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens after Aug 31st.

RFC patches sent for review only are obviously welcome at any time.

See:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

Signature · 2 lines
pw-bot: defer
pv-bot: closed