Skip to content

Commit

Permalink
net/mlx5: DR, Use swap() instead of open coding it
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Jiapeng Chong authored and Saeed Mahameed committed Dec 14, 2023
1 parent 9bb1ac8 commit 952f9a5
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 952f9a5

Please sign in to comment.