Skip to contentSkip to conversation

octeontx2-pf: mcs: Remove dead code and semi-colon from rsrc_name()

PATCH Superseded Nihar Chaithanya 2 participants 2 messages Jan 3, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 octeontx2-pf: mcs: Remove dead code and semi-colon from rsrc_name()

The switch-block has a default branch. Thus, the return statement at the end of the function can never be reached. The semi-colon is not required after switch-block.

Remove the semi-colon after the switch-block's curly braces and the return statement at the end of the function.

This issue was reported by Coverity Scan.
Report:
CID 1516236: (#1 of 1): Structurally dead code (UNREACHABLE)
unreachable: This code cannot be reached: return "Unknown";.

---
 drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c +1 -3
index 6cc7a78968fc..f3b9daffaec3 100644
@@ -133,9 +133,7 @@ static const char *rsrc_name(enum mcs_rsrc_type rsrc_type)
 		return "SA";
 	default:
 		return "Unknown";
-	};
-
-	return "Unknown";
+	}
 }
 
 static int cn10k_mcs_alloc_rsrc(struct otx2_nic *pfvf, enum mcs_direction dir,
Signature · 1 line
2.34.1
#1 lore raw
Quoted 2 lines · Nihar Chaithanya

The switch-block has a default branch. Thus, the return statement at the end of the function can never be reached.

Deja vue?

I already commented on a similar patch like this. It is not the
default: branch alone which makes the code unreachable. It is that every case statement makes a return, not a break. This might seem pedantic, but compiles and static analysers are pedantic, so we software engineers also need to be pedantic.

Please update the commit message.

Please also take a read of:

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

Andrew

---
pw-bot: cr