Skip to contentSkip to conversation

scsi: mpt3sas: clean up a couple sizeof() uses

PATCH Applied Dan Carpenter 3 participants 3 messages Jul 26, 2019 – Jul 30, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: mpt3sas: clean up a couple sizeof() uses

There is a copy and paste bug here. It uses EVENT_TRIGGERS size instead of SCSI_TRIGGERS size but fortunately both size are 84 bytes so it doesn't affect runtime.

These days the prefered style is to just say sizeof(object) instead of sizeof(type) so I have updated the function to the latest style as well.

---
v2: Update the style to the 21st Century

 drivers/scsi/mpt3sas/mpt3sas_ctl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_ctl.c +2 -3
index d4ecfbbe738c..41c54d4c9451 100644
@@ -3278,9 +3278,8 @@ diag_trigger_scsi_store(struct device *cdev,
 	ssize_t sz;
 
 	spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
-	sz = min(sizeof(struct SL_WH_SCSI_TRIGGERS_T), count);
-	memset(&ioc->diag_trigger_scsi, 0,
-	    sizeof(struct SL_WH_EVENT_TRIGGERS_T));
+	sz = min(sizeof(ioc->diag_trigger_scsi), count);
+	memset(&ioc->diag_trigger_scsi, 0, sizeof(ioc->diag_trigger_scsi));
 	memcpy(&ioc->diag_trigger_scsi, buf, sz);
 	if (ioc->diag_trigger_scsi.ValidEntries > NUM_VALID_ENTRIES)
 		ioc->diag_trigger_scsi.ValidEntries = NUM_VALID_ENTRIES;
Signature · 1 line
2.20.1
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 9 lines · Dan Carpenter

There is a copy and paste bug here. It uses EVENT_TRIGGERS size instead of SCSI_TRIGGERS size but fortunately both size are 84 bytes so it doesn't affect runtime.

These days the prefered style is to just say sizeof(object) instead of sizeof(type) so I have updated the function to the latest style as well.

Quoted 25 lines

---
v2: Update the style to the 21st Century

 drivers/scsi/mpt3sas/mpt3sas_ctl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_ctl.c +2 -4
index d4ecfbbe738c..41c54d4c9451 100644
@@ -3278,9 +3278,8 @@ diag_trigger_scsi_store(struct device *cdev,
        ssize_t sz;
 
        spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
-       sz = min(sizeof(struct SL_WH_SCSI_TRIGGERS_T), count);
-       memset(&ioc->diag_trigger_scsi, 0,
-           sizeof(struct SL_WH_EVENT_TRIGGERS_T));
+       sz = min(sizeof(ioc->diag_trigger_scsi), count);
+       memset(&ioc->diag_trigger_scsi, 0, sizeof(ioc->diag_trigger_scsi));
        memcpy(&ioc->diag_trigger_scsi, buf, sz);
        if (ioc->diag_trigger_scsi.ValidEntries > NUM_VALID_ENTRIES)
                ioc->diag_trigger_scsi.ValidEntries = NUM_VALID_ENTRIES;
--

2.20.1

#2 lore raw
In reply to Dan Carpenter

Dan,

Quoted 6 lines

There is a copy and paste bug here. It uses EVENT_TRIGGERS size instead of SCSI_TRIGGERS size but fortunately both size are 84 bytes so it doesn't affect runtime.

These days the prefered style is to just say sizeof(object) instead of sizeof(type) so I have updated the function to the latest style as well.

Applied to 5.4/scsi-queue. Thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering