netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Jiapeng Chong <jiapeng.chong@linux.alibaba.com>,
	Abaci Robot <abaci@linux.alibaba.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>
Subject: [net-next 11/11] net/mlx5: DR, Use swap() instead of open coding it
Date: Wed, 13 Dec 2023 18:08:32 -0800	[thread overview]
Message-ID: <20231214020832.50703-12-saeed@kernel.org> (raw)
In-Reply-To: <20231214020832.50703-1-saeed@kernel.org>

From: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

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>
---
 .../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.43.0


  parent reply	other threads:[~2023-12-14  2:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-14  2:08 [pull request][net-next 00/11] mlx5 updates 2023-12-13 Saeed Mahameed
2023-12-14  2:08 ` [net-next 01/11] net/mlx5: Add mlx5_ifc bits used for supporting single netdev Socket-Direct Saeed Mahameed
2023-12-14  2:08 ` [net-next 02/11] net/mlx5: Expose Management PCIe Index Register (MPIR) Saeed Mahameed
2023-12-14  2:08 ` [net-next 03/11] net/mlx5: fs, Command to control L2TABLE entry silent mode Saeed Mahameed
2023-12-14  2:08 ` [net-next 04/11] net/mlx5: fs, Command to control TX flow table root Saeed Mahameed
2023-12-14  2:08 ` [net-next 05/11] net/mlx5e: Remove TLS-specific logic in generic create TIS API Saeed Mahameed
2023-12-14  2:08 ` [net-next 06/11] net/mlx5: Move TISes from priv to mdev HW resources Saeed Mahameed
2023-12-14  2:08 ` [net-next 07/11] net/mlx5e: Statify function mlx5e_monitor_counter_arm Saeed Mahameed
2023-12-14  2:08 ` [net-next 08/11] net/mlx5e: Add wrapping for auxiliary_driver ops and remove unused args Saeed Mahameed
2023-12-14  2:08 ` [net-next 09/11] net/mlx5e: Decouple CQ from priv Saeed Mahameed
2023-12-14  2:08 ` [net-next 10/11] net/mlx5: devcom, Add component size getter Saeed Mahameed
2023-12-14  2:08 ` Saeed Mahameed [this message]
2023-12-19  0:03 ` [pull request][net-next 00/11] mlx5 updates 2023-12-13 Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231214020832.50703-12-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=abaci@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).