scsi: mpi3mr: Replace one-element arrays with flexible-array members
Subsystems (2)
PATCH v2 1/1 scsi: mpi3mr: Replace one-element arrays with flexible-array members
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element arrays with flexible-array members in multiple structures.
---
Change in v2:
- Use struct_size
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 11 +++-------- include/uapi/scsi/scsi_bsg_mpi3mr.h | 10 +++++----- 2 files changed, 8 insertions(+), 13 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +3 -8
@@ -1241,10 +1241,7 @@ static long mpi3mr_bsg_query_hdb(struct mpi3mr_ioc *mrioc,uint32_t data_in_sz =0 ; data_in_sz = job->request_payload.payload_len; - - length = (sizeof (*hbd_status) + ((MPI3MR_MAX_NUM_HDB -1 ) * -sizeof (*hbd_status_entry))); - hbd_status =kmalloc (length,GFP_KERNEL ); + hbd_status =kmalloc (struct_size (hbd_status, entry,MPI3MR_MAX_NUM_HDB ),GFP_KERNEL );if (!hbd_status)return -ENOMEM ; hbd_status_entry = &hbd_status->entry[0 ];
@@ -1466,7 +1463,7 @@ static long mpi3mr_bsg_pel_enable(struct mpi3mr_ioc *mrioc,static long mpi3mr_get_all_tgt_info (struct mpi3mr_ioc *mrioc,struct bsg_job *job) { -u16 num_devices =0 , i =0 , size; +u16 num_devices =0 , i =0 ;unsigned long flags;struct mpi3mr_tgt_dev *tgtdev;struct mpi3mr_device_map_info *devmap_info =NULL ;
@@ -1492,9 +1489,7 @@ static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc,return 0 ; } - kern_entrylen = num_devices *sizeof (*devmap_info); - size =sizeof (u64) + kern_entrylen; - alltgt_info =kzalloc (size,GFP_KERNEL ); + alltgt_info =kzalloc (struct_size (alltgt_info, dmi, num_devices),GFP_KERNEL );if (!alltgt_info)return -ENOMEM ;
include/uapi/scsi/scsi_bsg_mpi3mr.h +5 -5
@@ -205,7 +205,7 @@ struct mpi3mr_all_tgt_info {__u16 num_devices;__u16 rsvd1;__u32 rsvd2; -struct mpi3mr_device_map_info dmi[1 ]; +struct mpi3mr_device_map_info dmi[]; };/**
@@ -248,7 +248,7 @@ struct mpi3mr_logdata_entry {__u8 valid_entry;__u8 rsvd1;__u16 rsvd2; -__u8 data[1 ];/* Variable length Array */ +__u8 data[];/* Variable length Array */ };/**
@@ -259,7 +259,7 @@ struct mpi3mr_logdata_entry {* @entry: Variable length Log data entry array */ struct mpi3mr_bsg_in_log_data { -struct mpi3mr_logdata_entry entry[1 ]; + __DECLARE_FLEX_ARRAY(struct mpi3mr_logdata_entry, entry); };/**
@@ -307,7 +307,7 @@ struct mpi3mr_bsg_in_hdb_status {__u8 element_trigger_format;__u16 rsvd2;__u32 rsvd3; -struct mpi3mr_hdb_entry entry[1 ]; +struct mpi3mr_hdb_entry entry[]; };/**
@@ -416,7 +416,7 @@ struct mpi3mr_buf_entry_list {__u8 rsvd1;__u16 rsvd2;__u32 rsvd3; -struct mpi3mr_buf_entry buf_entry[1 ]; +struct mpi3mr_buf_entry buf_entry[]; };/** * struct mpi3mr_bsg_mptcmd - Generic bsg data
Signature · 1 line
2.39.5