diff mbox series

[net] net: marvell: prestera: Remove unneeded check in prestera_port_create()

Message ID 20240828132606.19878-1-amishin@t-argos.ru (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] net: marvell: prestera: Remove unneeded check in prestera_port_create() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 9 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
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 Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
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
netdev/contest fail net-next-2024-08-28--15-12 (tests: 710)

Commit Message

Aleksandr Mishin Aug. 28, 2024, 1:26 p.m. UTC
prestera_port_create() calls prestera_rxtx_port_init() and analyze its
return code. prestera_rxtx_port_init() always returns 0, so this check is
unneeded and should be removed.

Remove unneeded check to clean up the code.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 501ef3066c89 ("net: marvell: prestera: Add driver for Prestera family ASIC devices")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
 drivers/net/ethernet/marvell/prestera/prestera_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Maxime Chevallier Aug. 28, 2024, 2:03 p.m. UTC | #1
Hello Aleksandr,

On Wed, 28 Aug 2024 16:26:06 +0300
Aleksandr Mishin <amishin@t-argos.ru> wrote:

> prestera_port_create() calls prestera_rxtx_port_init() and analyze its
> return code. prestera_rxtx_port_init() always returns 0, so this check is
> unneeded and should be removed.
> 
> Remove unneeded check to clean up the code.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 501ef3066c89 ("net: marvell: prestera: Add driver for Prestera family ASIC devices")
> Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
> ---
>  drivers/net/ethernet/marvell/prestera/prestera_main.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> index 63ae01954dfc..2d4f6d03b729 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> @@ -718,9 +718,7 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
>  		}
>  	}
>  
> -	err = prestera_rxtx_port_init(port);
> -	if (err)
> -		goto err_port_init;
> +	prestera_rxtx_port_init(port);

If this function always return 0, you might as well change it to return
void. This would avoid future issues if one were to change
prestera_rxtx_port_init() to acually make it return something. It would
then become obvious that the caller doesn't check the return, whereas
with the current patch, we are simply ignoring it.

I also think you can target that patch to net-next, this isn't fixing
any bug, but rather cleans the code up.

Thanks,

Maxime
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
index 63ae01954dfc..2d4f6d03b729 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
@@ -718,9 +718,7 @@  static int prestera_port_create(struct prestera_switch *sw, u32 id)
 		}
 	}
 
-	err = prestera_rxtx_port_init(port);
-	if (err)
-		goto err_port_init;
+	prestera_rxtx_port_init(port);
 
 	INIT_DELAYED_WORK(&port->cached_hw_stats.caching_dw,
 			  &prestera_port_stats_update);