Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: scsi_transport_srp: Replace min/max nesting with clamp()

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>
Link: https://lore.kernel.org/r/202503311555115618U8Md16mKpRYOIy2TOmB6@zte.com.cn
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Li Haoran and committed by
Martin K. Petersen
a63b69f0 1fd2e77b

+1 -1
+1 -1
drivers/scsi/scsi_transport_srp.c
··· 388 388 "reconnect attempt %d failed (%d)\n", 389 389 ++rport->failed_reconnects, res); 390 390 delay = rport->reconnect_delay * 391 - min(100, max(1, rport->failed_reconnects - 10)); 391 + clamp(rport->failed_reconnects - 10, 1, 100); 392 392 if (delay > 0) 393 393 queue_delayed_work(system_long_wq, 394 394 &rport->reconnect_work, delay * HZ);