From: Bart Van Assche <bvanassche@acm.org>
To: shao.mingyin@zte.com.cn, james.bottomley@hansenpartnership.com
Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, yang.yang29@zte.com.cn,
xu.xin16@zte.com.cn, ye.xingchen@zte.com.cn,
li.haoran7@zte.com.cn
Subject: Re: [PATCH] scsi: scsi_transport_srp: replace min/max nesting with clamp()
Date: Tue, 1 Apr 2025 08:59:51 -0700 [thread overview]
Message-ID: <93e62d17-81df-454f-9e35-7cede36bc162@acm.org> (raw)
In-Reply-To: <202503311555115618U8Md16mKpRYOIy2TOmB6@zte.com.cn>
On 3/31/25 12:55 AM, shao.mingyin@zte.com.cn wrote:
> From: Li Haoran <li.haoran7@zte.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@zte.com.cn>
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.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@acm.org>
next prev parent reply other threads:[~2025-04-01 16:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-31 7:55 shao.mingyin
2025-04-01 15:59 ` Bart Van Assche [this message]
2025-04-03 14:55 ` Martin K. Petersen
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=93e62d17-81df-454f-9e35-7cede36bc162@acm.org \
--to=bvanassche@acm.org \
--cc=james.bottomley@hansenpartnership.com \
--cc=li.haoran7@zte.com.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=shao.mingyin@zte.com.cn \
--cc=xu.xin16@zte.com.cn \
--cc=yang.yang29@zte.com.cn \
--cc=ye.xingchen@zte.com.cn \
/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
all inboxes | Powered by JetHome®