netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/mlx4: Remove redundant ternary operators
@ 2025-08-27 12:15 Liao Yuanhong
  2025-08-28  2:46 ` Zhu Yanjun
  2025-08-28 19:09 ` Simon Horman
  0 siblings, 2 replies; 3+ messages in thread
From: Liao Yuanhong @ 2025-08-27 12:15 UTC (permalink / raw)
  To: Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni,
	open list:MELLANOX MLX4 core VPI driver,
	open list:MELLANOX MLX4 core VPI driver, open list
  Cc: 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;
 }
 
 int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac)
-- 
2.34.1


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

* Re: [PATCH net-next] net/mlx4: Remove redundant ternary operators
  2025-08-27 12:15 [PATCH net-next] net/mlx4: Remove redundant ternary operators Liao Yuanhong
@ 2025-08-28  2:46 ` Zhu Yanjun
  2025-08-28 19:09 ` Simon Horman
  1 sibling, 0 replies; 3+ messages in thread
From: Zhu Yanjun @ 2025-08-28  2:46 UTC (permalink / raw)
  To: Liao Yuanhong, Tariq Toukan, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list:MELLANOX MLX4 core VPI driver,
	open list:MELLANOX MLX4 core VPI driver, open list

在 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)


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

* Re: [PATCH net-next] net/mlx4: Remove redundant ternary operators
  2025-08-27 12:15 [PATCH net-next] net/mlx4: Remove redundant ternary operators Liao Yuanhong
  2025-08-28  2:46 ` Zhu Yanjun
@ 2025-08-28 19:09 ` Simon Horman
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-08-28 19:09 UTC (permalink / raw)
  To: Liao Yuanhong
  Cc: Tariq Toukan, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni,
	open list:MELLANOX MLX4 core VPI driver,
	open list:MELLANOX MLX4 core VPI driver, open list

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


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

end of thread, other threads:[~2025-08-28 19:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27 12:15 [PATCH net-next] net/mlx4: Remove redundant ternary operators Liao Yuanhong
2025-08-28  2:46 ` Zhu Yanjun
2025-08-28 19:09 ` Simon Horman

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).