linux/drivers/scsi/megaraid
Gustavo A. R. Silva e58ed5002f scsi: megaraid_sas: Use struct_size() helper
One of the more common cases of allocation size calculations is finding the
size of a structure that has a zero-sized array at the end, along with
memory for some number of elements for that array. For example:

struct MR_PD_CFG_SEQ_NUM_SYNC {
	...
        struct MR_PD_CFG_SEQ seq[1];
} __packed;

Make use of the struct_size() helper instead of an open-coded version in
order to avoid any potential type mistakes.

So, replace the following form:

sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) + (sizeof(struct MR_PD_CFG_SEQ) * (MAX_PHYSICAL_DEVICES - 1))

with:

struct_size(pd_sync, seq, MAX_PHYSICAL_DEVICES - 1)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-06-20 15:37:03 -04:00
..
Kconfig.megaraid scsi: megaraid_sas: IRQ poll to avoid CPU hard lockups 2019-06-18 19:46:19 -04:00
Makefile scsi: megaraid_sas: Export RAID map through debugfs 2019-06-18 19:46:20 -04:00
mbox_defs.h
mega_common.h
megaraid_ioctl.h scsi: megaraid: Convert timers to use timer_setup() 2017-11-01 11:27:08 -07:00
megaraid_mbox.c cross-tree: phase out dma_zalloc_coherent() 2019-01-08 07:58:37 -05:00
megaraid_mbox.h scsi: megaraid: fix spelling mistake "maibox" -> "mailbox" 2018-09-25 20:59:27 -04:00
megaraid_mm.c scsi: megaraid_sas: NULL check before some freeing functions is not needed 2018-12-07 21:46:22 -05:00
megaraid_mm.h Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
megaraid_sas_base.c scsi: megaraid_sas: use DEVICE_ATTR_{RO, RW} 2019-06-18 19:46:25 -04:00
megaraid_sas_debugfs.c scsi: megaraid_sas: Remove unused including <linux/version.h> 2019-06-18 19:46:25 -04:00
megaraid_sas_fp.c scsi: megaraid_sas: use octal permissions instead of constants 2019-06-18 19:46:25 -04:00
megaraid_sas_fusion.c scsi: megaraid_sas: Use struct_size() helper 2019-06-20 15:37:03 -04:00
megaraid_sas_fusion.h scsi: megaraid_sas: Export RAID map through debugfs 2019-06-18 19:46:20 -04:00
megaraid_sas.h scsi: megaraid_sas: Update driver version to 07.708.03.00 2019-06-18 19:46:20 -04:00