Skip to content

Commit bb26224

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Use struct_size() helper
Prefer struct_size() over open-coded versions of idiom: sizeof(struct-with-flex-array) + sizeof(typeof-flex-array-elements) * count where count is the max number of items the flexible array is supposed to contain. Link: KSPP#160 Co-developed-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Co-developed-by: Kees Cook <[email protected]> Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Justin Tee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 9c24f90 commit bb26224

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/scsi/lpfc/lpfc_ct.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3748,8 +3748,7 @@ lpfc_vmid_cmd(struct lpfc_vport *vport,
37483748
rap->obj[0].entity_id_len = vmid->vmid_len;
37493749
memcpy(rap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len);
37503750
size = RAPP_IDENT_OFFSET +
3751-
sizeof(struct lpfc_vmid_rapp_ident_list) +
3752-
sizeof(struct entity_id_object);
3751+
struct_size(rap, obj, be32_to_cpu(rap->no_of_objects));
37533752
retry = 1;
37543753
break;
37553754

@@ -3768,8 +3767,7 @@ lpfc_vmid_cmd(struct lpfc_vport *vport,
37683767
dap->obj[0].entity_id_len = vmid->vmid_len;
37693768
memcpy(dap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len);
37703769
size = DAPP_IDENT_OFFSET +
3771-
sizeof(struct lpfc_vmid_dapp_ident_list) +
3772-
sizeof(struct entity_id_object);
3770+
struct_size(dap, obj, be32_to_cpu(dap->no_of_objects));
37733771
write_lock(&vport->vmid_lock);
37743772
vmid->flag &= ~LPFC_VMID_REGISTERED;
37753773
write_unlock(&vport->vmid_lock);

0 commit comments

Comments
 (0)