scsi: lpfc: Replace one-element array with flexible-array member

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 a couple of structures, and refactor the rest of the code,
accordingly.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines
on memcpy() and help us make progress towards globally enabling
-fstrict-flex-arrays=3 [1].

This results in no differences in binary output.

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/295
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/6c6dcab88524c14c47fd06b9332bd96162656db5.1684358315.git.gustavoars@kernel.org
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Gustavo A. R. Silva 2023-05-17 15:22:45 -06:00 коммит произвёл Martin K. Petersen
Родитель 144679dfb5
Коммит e90644b0ce
2 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -3748,7 +3748,8 @@ lpfc_vmid_cmd(struct lpfc_vport *vport,
rap->obj[0].entity_id_len = vmid->vmid_len;
memcpy(rap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len);
size = RAPP_IDENT_OFFSET +
sizeof(struct lpfc_vmid_rapp_ident_list);
sizeof(struct lpfc_vmid_rapp_ident_list) +
sizeof(struct entity_id_object);
retry = 1;
break;
@ -3767,7 +3768,8 @@ lpfc_vmid_cmd(struct lpfc_vport *vport,
dap->obj[0].entity_id_len = vmid->vmid_len;
memcpy(dap->obj[0].entity_id, vmid->host_vmid, vmid->vmid_len);
size = DAPP_IDENT_OFFSET +
sizeof(struct lpfc_vmid_dapp_ident_list);
sizeof(struct lpfc_vmid_dapp_ident_list) +
sizeof(struct entity_id_object);
write_lock(&vport->vmid_lock);
vmid->flag &= ~LPFC_VMID_REGISTERED;
write_unlock(&vport->vmid_lock);

Просмотреть файл

@ -1415,12 +1415,12 @@ struct app_id_object {
struct lpfc_vmid_rapp_ident_list {
uint32_t no_of_objects;
struct entity_id_object obj[1];
struct entity_id_object obj[];
};
struct lpfc_vmid_dapp_ident_list {
uint32_t no_of_objects;
struct entity_id_object obj[1];
struct entity_id_object obj[];
};
#define GALLAPPIA_ID_LAST 0x80