[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250212115557.111263-2-thorsten.blum@linux.dev>
Date: Wed, 12 Feb 2025 12:55:57 +0100
From: Thorsten Blum <thorsten.blum@...ux.dev>
To: Don Brace <don.brace@...rochip.com>,
"James E.J. Bottomley" <James.Bottomley@...senPartnership.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>
Cc: Thorsten Blum <thorsten.blum@...ux.dev>,
storagedev@...rochip.com,
linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] scsi: hpsa: Use min() to simplify code
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@...ux.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
Powered by blists - more mailing lists