netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: DR, Use swap() instead of open coding it
@ 2023-11-17  7:19 Jiapeng Chong
  2023-11-17  9:18 ` Przemek Kitszel
  2023-12-06 22:37 ` Saeed Mahameed
  0 siblings, 2 replies; 3+ messages in thread
From: Jiapeng Chong @ 2023-11-17  7:19 UTC (permalink / raw)
  To: saeedm
  Cc: leon, davem, edumazet, kuba, pabeni, netdev, linux-rdma,
	linux-kernel, Jiapeng Chong, Abaci Robot

Swap is a function interface that provides exchange function. To avoid
code duplication, we can use swap function.

./drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c:1254:50-51: WARNING opportunity for swap().

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7580
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 .../net/ethernet/mellanox/mlx5/core/steering/dr_action.c  | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
index e3ec559369fa..6f9790e97fed 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
@@ -1170,7 +1170,6 @@ mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
 				   bool ignore_flow_level,
 				   u32 flow_source)
 {
-	struct mlx5dr_cmd_flow_destination_hw_info tmp_hw_dest;
 	struct mlx5dr_cmd_flow_destination_hw_info *hw_dests;
 	struct mlx5dr_action **ref_actions;
 	struct mlx5dr_action *action;
@@ -1249,11 +1248,8 @@ mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
 	 * one that done in the TX.
 	 * So, if one of the ft target is wire, put it at the end of the dest list.
 	 */
-	if (is_ft_wire && num_dst_ft > 1) {
-		tmp_hw_dest = hw_dests[last_dest];
-		hw_dests[last_dest] = hw_dests[num_of_dests - 1];
-		hw_dests[num_of_dests - 1] = tmp_hw_dest;
-	}
+	if (is_ft_wire && num_dst_ft > 1)
+		swap(hw_dests[last_dest], hw_dests[num_of_dests - 1]);
 
 	action = dr_action_create_generic(DR_ACTION_TYP_FT);
 	if (!action)
-- 
2.20.1.7.g153144c


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net/mlx5: DR, Use swap() instead of open coding it
  2023-11-17  7:19 [PATCH] net/mlx5: DR, Use swap() instead of open coding it Jiapeng Chong
@ 2023-11-17  9:18 ` Przemek Kitszel
  2023-12-06 22:37 ` Saeed Mahameed
  1 sibling, 0 replies; 3+ messages in thread
From: Przemek Kitszel @ 2023-11-17  9:18 UTC (permalink / raw)
  To: Jiapeng Chong, saeedm
  Cc: leon, davem, edumazet, kuba, pabeni, netdev, linux-rdma,
	linux-kernel, Abaci Robot

On 11/17/23 08:19, Jiapeng Chong wrote:
> Swap is a function interface that provides exchange function. To avoid
> code duplication, we can use swap function.
> 
> ./drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c:1254:50-51: WARNING opportunity for swap().
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7580
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>   .../net/ethernet/mellanox/mlx5/core/steering/dr_action.c  | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
> index e3ec559369fa..6f9790e97fed 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
> @@ -1170,7 +1170,6 @@ mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
>   				   bool ignore_flow_level,
>   				   u32 flow_source)
>   {
> -	struct mlx5dr_cmd_flow_destination_hw_info tmp_hw_dest;
>   	struct mlx5dr_cmd_flow_destination_hw_info *hw_dests;
>   	struct mlx5dr_action **ref_actions;
>   	struct mlx5dr_action *action;
> @@ -1249,11 +1248,8 @@ mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
>   	 * one that done in the TX.
>   	 * So, if one of the ft target is wire, put it at the end of the dest list.
>   	 */
> -	if (is_ft_wire && num_dst_ft > 1) {
> -		tmp_hw_dest = hw_dests[last_dest];
> -		hw_dests[last_dest] = hw_dests[num_of_dests - 1];
> -		hw_dests[num_of_dests - 1] = tmp_hw_dest;
> -	}
> +	if (is_ft_wire && num_dst_ft > 1)
> +		swap(hw_dests[last_dest], hw_dests[num_of_dests - 1]);
>   
>   	action = dr_action_create_generic(DR_ACTION_TYP_FT);
>   	if (!action)

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>

For future non-bugfix contributions please target patches to net-next

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net/mlx5: DR, Use swap() instead of open coding it
  2023-11-17  7:19 [PATCH] net/mlx5: DR, Use swap() instead of open coding it Jiapeng Chong
  2023-11-17  9:18 ` Przemek Kitszel
@ 2023-12-06 22:37 ` Saeed Mahameed
  1 sibling, 0 replies; 3+ messages in thread
From: Saeed Mahameed @ 2023-12-06 22:37 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: saeedm, leon, davem, edumazet, kuba, pabeni, netdev, linux-rdma,
	linux-kernel, Abaci Robot

On 17 Nov 15:19, Jiapeng Chong wrote:
>Swap is a function interface that provides exchange function. To avoid
>code duplication, we can use swap function.
>
>./drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c:1254:50-51: WARNING opportunity for swap().
>
>Reported-by: Abaci Robot <abaci@linux.alibaba.com>
>Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7580
>Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
>---

applied to net-next-mlx5
-Saeed.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-06 22:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-17  7:19 [PATCH] net/mlx5: DR, Use swap() instead of open coding it Jiapeng Chong
2023-11-17  9:18 ` Przemek Kitszel
2023-12-06 22:37 ` Saeed Mahameed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).