diff options
author | Gustavo A. R. Silva <gustavoars@kernel.org> | 2025-08-27 08:10:53 +0200 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2025-08-30 21:42:19 -0400 |
commit | 44b6169ada7fe3cf4cb91e6b06019eaa22719f28 (patch) | |
tree | 8a09f860c01ba5db08244ca137b69e6e85dd25b2 /rust/helpers/platform.c | |
parent | bee3554d1a4efbce91d6eca732f41b97272213a5 (diff) |
scsi: fc: Avoid -Wflex-array-member-not-at-end warnings
-Wflex-array-member-not-at-end has been introduced in GCC-14, and we are
getting ready to enable it, globally.
So, in order to avoid ending up with a flexible-array member in the
middle of multiple other structs, we use the '__struct_group()' helper
to create a new tagged 'struct fc_df_desc_fpin_reg_hdr'. This structure
groups together all the members of the flexible 'struct
fc_df_desc_fpin_reg' except the flexible array.
As a result, the array is effectively separated from the rest of the
members without modifying the memory layout of the flexible structure.
We then change the type of the middle struct members currently causing
trouble from 'struct fc_df_desc_fpin_reg' to 'struct
fc_df_desc_fpin_reg_hdr'.
We also want to ensure that in case new members need to be added to the
flexible structure, they are always included within the newly created
tagged struct. For this, we use '_Static_assert()'. This ensures that
the memory layout for both the flexible structure and the new tagged
struct is the same after any changes.
This approach avoids having to implement 'struct fc_df_desc_fpin_reg_hdr'
as a completely separate structure, thus preventing having to maintain
two independent but basically identical structures, closing the door
to potential bugs in the future.
The above is also done for flexible structures 'struct fc_els_rdf' and
'struct fc_els_rdf_resp'
So, with these changes, fix the following warnings:
drivers/scsi/lpfc/lpfc_hw4.h:4936:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/scsi/lpfc/lpfc_hw4.h:4942:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/scsi/lpfc/lpfc_hw4.h:4947:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/aK6hbQLyQlvlySf8@kspp
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'rust/helpers/platform.c')
0 files changed, 0 insertions, 0 deletions