diff mbox series

scsi: hpsa: Use min helper for comparison and assignment

Message ID Y9UnT4j51kHrMvhm@ubun2204.myguest.virtualbox.org
State New
Headers show
Series scsi: hpsa: Use min helper for comparison and assignment | expand

Commit Message

Deepak R Varma Jan. 28, 2023, 1:46 p.m. UTC
Simplify code by using min_t() helper macro for logical evaluation
and value assignment. Use the _t variant macro since the variable
types are not same.
Proposed change is identified using minmax.cocci semantic patch script.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
 drivers/scsi/hpsa.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index c74fec4c2bd6..e030d07c4341 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2665,12 +2665,10 @@  static void complete_scsi_command(struct CommandList *cp)
 	case CMD_TARGET_STATUS:
 		cmd->result |= ei->ScsiStatus;
 		/* copy the sense data */
-		if (SCSI_SENSE_BUFFERSIZE < sizeof(ei->SenseInfo))
-			sense_data_size = SCSI_SENSE_BUFFERSIZE;
-		else
-			sense_data_size = sizeof(ei->SenseInfo);
+		sense_data_size = min_t(size_t, SCSI_SENSE_BUFFERSIZE, sizeof(ei->SenseInfo));
 		if (ei->SenseLen < sense_data_size)
 			sense_data_size = ei->SenseLen;
+
 		memcpy(cmd->sense_buffer, ei->SenseInfo, sense_data_size);
 		if (ei->ScsiStatus)
 			decode_sense_data(ei->SenseInfo, sense_data_size,
@@ -3630,11 +3628,9 @@  static bool hpsa_vpd_page_supported(struct ctlr_info *h,
 				buf, HPSA_VPD_HEADER_SZ);
 	if (rc != 0)
 		goto exit_unsupported;
+
 	pages = buf[3];
-	if ((pages + HPSA_VPD_HEADER_SZ) <= 255)
-		bufsize = pages + HPSA_VPD_HEADER_SZ;
-	else
-		bufsize = 255;
+	bufsize = min_t(uint, (pages + HPSA_VPD_HEADER_SZ), 255);
 
 	/* Get the whole VPD page list */
 	rc = hpsa_scsi_do_inquiry(h, scsi3addr,