diff mbox series

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

Message ID 20250103155824.131285-1-niharchaithanya@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series octeontx2-pf: mcs: Remove dead code and semi-colon from rsrc_name() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: bbhushan2@marvell.com
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Nihar Chaithanya Jan. 3, 2025, 3:58 p.m. UTC
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";.

Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
---
 drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Andrew Lunn Jan. 3, 2025, 4:36 p.m. UTC | #1
On Fri, Jan 03, 2025 at 09:28:26PM +0530, Nihar Chaithanya wrote:
> 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
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c
index 6cc7a78968fc..f3b9daffaec3 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c
@@ -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,