drivers/net/ethernet/mellanox/mlx4/port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
For ternary operators in the form of "a ? true : false", if 'a' itself
returns a boolean result, the ternary operator can be omitted. Remove
redundant ternary operators to clean up the code.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
---
drivers/net/ethernet/mellanox/mlx4/port.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c
index e3d0b13c1610..5abdb1363ccc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/port.c
@@ -156,7 +156,7 @@ static bool mlx4_need_mf_bond(struct mlx4_dev *dev)
mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH)
++num_eth_ports;
- return (num_eth_ports == 2) ? true : false;
+ return num_eth_ports == 2;
}
int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac)
--
2.34.1
On Wed, Aug 27, 2025 at 08:15:03PM +0800, Liao Yuanhong wrote: > For ternary operators in the form of "a ? true : false", if 'a' itself > returns a boolean result, the ternary operator can be omitted. Remove > redundant ternary operators to clean up the code. > > Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com> Quoting documentation: Clean-up patches ~~~~~~~~~~~~~~~~ Netdev discourages patches which perform simple clean-ups, which are not in the context of other work. For example: * Addressing ``checkpatch.pl`` warnings * Addressing :ref:`Local variable ordering<rcs>` issues * Conversions to device-managed APIs (``devm_`` helpers) This is because it is felt that the churn that such changes produce comes at a greater cost than the value of such clean-ups. Conversely, spelling and grammar fixes are not discouraged. See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#clean-up-patches -- pw-bot: cr
在 2025/8/27 5:15, Liao Yuanhong 写道: > For ternary operators in the form of "a ? true : false", if 'a' itself > returns a boolean result, the ternary operator can be omitted. Remove > redundant ternary operators to clean up the code. > > Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com> > --- > drivers/net/ethernet/mellanox/mlx4/port.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c > index e3d0b13c1610..5abdb1363ccc 100644 > --- a/drivers/net/ethernet/mellanox/mlx4/port.c > +++ b/drivers/net/ethernet/mellanox/mlx4/port.c > @@ -156,7 +156,7 @@ static bool mlx4_need_mf_bond(struct mlx4_dev *dev) > mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) > ++num_eth_ports; > > - return (num_eth_ports == 2) ? true : false; > + return num_eth_ports == 2; Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev> Zhu Yanjun > } > > int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac)
© 2016 - 2025 Red Hat, Inc.