diff mbox series

[v1,net-next] net: ethernet: mellanox: mlx5: core: Use ERR_CAST() to return

Message ID 20240829081404.2898004-1-yanzhen@vivo.com (mailing list archive)
State Not Applicable
Headers show
Series [v1,net-next] net: ethernet: mellanox: mlx5: core: Use ERR_CAST() to return | expand

Commit Message

Yan Zhen Aug. 29, 2024, 8:14 a.m. UTC
Using ERR_CAST() is more reasonable and safer, When it is necessary
to convert the type of an error pointer and return it.

Signed-off-by: Yan Zhen <yanzhen@vivo.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Sept. 6, 2024, 7:32 a.m. UTC | #1
On Thu, Aug 29, 2024 at 04:14:04PM +0800, Yan Zhen wrote:
> Using ERR_CAST() is more reasonable and safer, When it is necessary
> to convert the type of an error pointer and return it.
> 
> Signed-off-by: Yan Zhen <yanzhen@vivo.com>

Thanks,

I agree that this change is correct.
And it seems to be the only case where this change is
relevant in this file.

And, personally, I do see a value in reducing naked casts,
even if the macro is doing much the same thing. Because
using a macro is more expressive about intent.

But, OTOH, I do see that there is a cost in terms of code-churn,
something for the maintainer to weigh-up.

Reviewed-by: Simon Horman <horms@kernel.org>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
index 773624bb2c5d..2a0f70987749 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
@@ -130,7 +130,7 @@  static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv,
 	ft_attr.autogroup.max_num_groups = MLX5E_ETHTOOL_NUM_GROUPS;
 	ft = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
 	if (IS_ERR(ft))
-		return (void *)ft;
+		return ERR_CAST(ft);
 
 	eth_ft->ft = ft;
 	return eth_ft;