From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
Kashyap Desai <kashyap.desai@broadcom.com>,
Sumit Saxena <sumit.saxena@broadcom.com>,
Shivasharan S <shivasharan.srikanteshwara@broadcom.com>,
Chandrakanth patil <chandrakanth.patil@broadcom.com>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2][next] scsi: megaraid_sas: Avoid a couple -Wflex-array-member-not-at-end warnings
Date: Tue, 7 Oct 2025 11:43:04 +0100 [thread overview]
Message-ID: <3a80fd1d-5a05-4db3-9dda-3ad38bedfb38@embeddedor.com> (raw)
In-Reply-To: <aM1E7Xa8qYdZ598N@kspp>
Hi all,
Friendly ping: who can take this, please?
Thanks!
-Gustavo
On 9/19/25 12:56, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
>
> Use the new TRAILING_OVERLAP() helper to fix the following warnings:
>
> drivers/scsi/megaraid/megaraid_sas_fusion.h:1153:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/scsi/megaraid/megaraid_sas_fusion.h:1198:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>
> This helper creates a union between a flexible-array member (FAM)
> and a set of MEMBERS that would otherwise follow it --in this case
> `struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES_DYN]` and
> `struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES]` in the
> corresponding structures.
>
> This overlays the trailing members onto the FAM (struct MR_LD_SPAN_MAP
> ldSpanMap[];) while keeping the FAM and the start of MEMBERS aligned.
>
> The static_assert() ensures this alignment remains, and it's intentionally
> placed inmediately after the corresponding structures --no blank line in
> between.
>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
> Changes in v2:
> - Update changelog text --remove reference to unrelated structure.
>
> v1:
> - Link: https://lore.kernel.org/linux-hardening/aM1D4nPVH96DglfT@kspp/
>
> drivers/scsi/megaraid/megaraid_sas_fusion.h | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
> index b677d80e5874..ddeea0ee2834 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
> +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
> @@ -1150,9 +1150,13 @@ typedef struct LOG_BLOCK_SPAN_INFO {
> } LD_SPAN_INFO, *PLD_SPAN_INFO;
>
> struct MR_FW_RAID_MAP_ALL {
> - struct MR_FW_RAID_MAP raidMap;
> - struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES];
> + /* Must be last --ends in a flexible-array member. */
> + TRAILING_OVERLAP(struct MR_FW_RAID_MAP, raidMap, ldSpanMap,
> + struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES];
> + );
> } __attribute__ ((packed));
> +static_assert(offsetof(struct MR_FW_RAID_MAP_ALL, raidMap.ldSpanMap) ==
> + offsetof(struct MR_FW_RAID_MAP_ALL, ldSpanMap));
>
> struct MR_DRV_RAID_MAP {
> /* total size of this structure, including this field.
> @@ -1194,10 +1198,13 @@ struct MR_DRV_RAID_MAP {
> * And it is mainly for code re-use purpose.
> */
> struct MR_DRV_RAID_MAP_ALL {
> -
> - struct MR_DRV_RAID_MAP raidMap;
> - struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES_DYN];
> + /* Must be last --ends in a flexible-array member. */
> + TRAILING_OVERLAP(struct MR_DRV_RAID_MAP, raidMap, ldSpanMap,
> + struct MR_LD_SPAN_MAP ldSpanMap[MAX_LOGICAL_DRIVES_DYN];
> + );
> } __packed;
> +static_assert(offsetof(struct MR_DRV_RAID_MAP_ALL, raidMap.ldSpanMap) ==
> + offsetof(struct MR_DRV_RAID_MAP_ALL, ldSpanMap));
>
>
>
next prev parent reply other threads:[~2025-10-07 10:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 11:56 [PATCH v2][next] scsi: megaraid_sas: Avoid a couple -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-10-07 10:43 ` Gustavo A. R. Silva [this message]
2025-10-07 11:59 ` James Bottomley
2025-10-07 14:18 ` Gustavo A. R. Silva
2025-10-07 22:56 ` James Bottomley
2025-10-08 9:28 ` Gustavo A. R. Silva
2025-10-14 21:55 ` Martin K. Petersen
2025-10-14 21:47 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3a80fd1d-5a05-4db3-9dda-3ad38bedfb38@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=chandrakanth.patil@broadcom.com \
--cc=gustavoars@kernel.org \
--cc=kashyap.desai@broadcom.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=megaraidlinux.pdl@broadcom.com \
--cc=shivasharan.srikanteshwara@broadcom.com \
--cc=sumit.saxena@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox