Message ID | 20211104011737.1028163-1-yang.guang5@zte.com.cn (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | net/mlx5: use swap() to make code cleaner | expand |
On Thu, 2021-11-04 at 09:17 +0800, davidcomponentone@gmail.com wrote: > From: Yang Guang <yang.guang5@zte.com.cn> > > Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid > opencoding it. > > Reported-by: Zeal Robot <zealci@zte.com.cn> > Signed-off-by: Yang Guang <yang.guang5@zte.com.cn> sorry you're too late, another patch was already submitted: https://patchwork.kernel.org/project/netdevbpf/patch/20211103062111.3286-1-hanyihao@vivo.com/
On Thu, 2021-11-04 at 09:17 +0800, davidcomponentone@gmail.com wrote: > From: Yang Guang <yang.guang5@zte.com.cn> > > Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid > opencoding it. > > Reported-by: Zeal Robot <zealci@zte.com.cn> > Signed-off-by: Yang Guang <yang.guang5@zte.com.cn> > --- > drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c > b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c > index c1c6e74c79c4..8ce4b6112169 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c > @@ -907,12 +907,9 @@ mlx5_tc_ct_shared_counter_get(struct > mlx5_tc_ct_priv *ct_priv, > struct mlx5_ct_tuple rev_tuple = entry->tuple; > struct mlx5_ct_counter *shared_counter; > struct mlx5_ct_entry *rev_entry; > - __be16 tmp_port; > > /* get the reversed tuple */ > - tmp_port = rev_tuple.port.src; > - rev_tuple.port.src = rev_tuple.port.dst; > - rev_tuple.port.dst = tmp_port; > + swap(rev_tuple.port.src, rev_tuple.port.dst); > > if (rev_tuple.addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) { > __be32 tmp_addr = rev_tuple.ip.src_v4; An identical patch was already submitted the day before. Thanks for the effort !
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c index c1c6e74c79c4..8ce4b6112169 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c @@ -907,12 +907,9 @@ mlx5_tc_ct_shared_counter_get(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_tuple rev_tuple = entry->tuple; struct mlx5_ct_counter *shared_counter; struct mlx5_ct_entry *rev_entry; - __be16 tmp_port; /* get the reversed tuple */ - tmp_port = rev_tuple.port.src; - rev_tuple.port.src = rev_tuple.port.dst; - rev_tuple.port.dst = tmp_port; + swap(rev_tuple.port.src, rev_tuple.port.dst); if (rev_tuple.addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) { __be32 tmp_addr = rev_tuple.ip.src_v4;