[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <93e62d17-81df-454f-9e35-7cede36bc162@acm.org>
Date: Tue, 1 Apr 2025 08:59:51 -0700
From: Bart Van Assche <bvanassche@....org>
To: shao.mingyin@....com.cn, james.bottomley@...senpartnership.com
Cc: martin.petersen@...cle.com, linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org, yang.yang29@....com.cn, xu.xin16@....com.cn,
ye.xingchen@....com.cn, li.haoran7@....com.cn
Subject: Re: [PATCH] scsi: scsi_transport_srp: replace min/max nesting with
clamp()
On 3/31/25 12:55 AM, shao.mingyin@....com.cn wrote:
> From: Li Haoran <li.haoran7@....com.cn>
>
> This patch replaces min(a, max(b, c)) by clamp(val, lo, hi) in the SRP
> transport layer. The clamp() macro explicitly expresses the intent of
> constraining a value within bounds, improving code readability.
>
> Signed-off-by: Li Haoran <li.haoran7@....com.cn>
> Signed-off-by: Shao Mingyin <shao.mingyin@....com.cn>
> ---
> drivers/scsi/scsi_transport_srp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
> index 64f6b22e8cc0..aeb58a9e6b7f 100644
> --- a/drivers/scsi/scsi_transport_srp.c
> +++ b/drivers/scsi/scsi_transport_srp.c
> @@ -388,7 +388,7 @@ static void srp_reconnect_work(struct work_struct *work)
> "reconnect attempt %d failed (%d)\n",
> ++rport->failed_reconnects, res);
> delay = rport->reconnect_delay *
> - min(100, max(1, rport->failed_reconnects - 10));
> + clamp(rport->failed_reconnects - 10, 1, 100);
> if (delay > 0)
> queue_delayed_work(system_long_wq,
> &rport->reconnect_work, delay * HZ);
Reviewed-by: Bart Van Assche <bvanassche@....org>
Powered by blists - more mailing lists