public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: hpsa: Use min() to simplify code
@ 2025-02-12 11:55 Thorsten Blum
  2025-02-12 18:48 ` Bart Van Assche
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2025-02-12 11:55 UTC (permalink / raw)
  To: Don Brace, James E.J. Bottomley, Martin K. Petersen
  Cc: Thorsten Blum, storagedev, linux-scsi, linux-kernel

Use min() to simplify the host_store_hp_ssd_smart_path_status() and
host_store_raid_offload_debug() functions.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/scsi/hpsa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 84d8de07b7ae..1d19eb2ca1d3 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -460,7 +460,7 @@ static ssize_t host_store_hp_ssd_smart_path_status(struct device *dev,
 
 	if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
 		return -EACCES;
-	len = count > sizeof(tmpbuf) - 1 ? sizeof(tmpbuf) - 1 : count;
+	len = min(count, sizeof(tmpbuf) - 1);
 	strncpy(tmpbuf, buf, len);
 	tmpbuf[len] = '\0';
 	if (sscanf(tmpbuf, "%d", &status) != 1)
@@ -484,7 +484,7 @@ static ssize_t host_store_raid_offload_debug(struct device *dev,
 
 	if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
 		return -EACCES;
-	len = count > sizeof(tmpbuf) - 1 ? sizeof(tmpbuf) - 1 : count;
+	len = min(count, sizeof(tmpbuf) - 1);
 	strncpy(tmpbuf, buf, len);
 	tmpbuf[len] = '\0';
 	if (sscanf(tmpbuf, "%d", &debug_level) != 1)
-- 
2.48.1


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

end of thread, other threads:[~2025-02-12 22:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12 11:55 [PATCH] scsi: hpsa: Use min() to simplify code Thorsten Blum
2025-02-12 18:48 ` Bart Van Assche
2025-02-12 22:28   ` Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox