From: "Pedro Falcato" <pedro.falcato@gmail.com>
To: devel@edk2.groups.io, yeoreum.yun@arm.com
Cc: "nd@arm.com" <nd@arm.com>, "sami.mujawar@arm.com" <sami.mujawar@arm.com>
Subject: Re: [edk2-devel] [Question] using Flexible Array Member in Structure.
Date: Fri, 5 Apr 2024 08:34:56 +0100 [thread overview]
Message-ID: <CAKbZUD0fP8LZYfc8btaD0Ea53h3bjUuMharMfow6Tt+ZZpSs0A@mail.gmail.com> (raw)
In-Reply-To: <a0f22482-e945-4f24-a64f-ad7ed62420bb@arm.com>
On Wed, Apr 3, 2024 at 10:27 AM levi.yun <yeoreum.yun@arm.com> wrote:
>
> Hello all!
>
> while I see the code. I have one question related using Flexible Array
> Member.
>
> For example)
>
> ///
> /// Socket Type Data.
> ///
> typedef struct {
> EFI_ACPI_6_4_PMTT_COMMON_MEMORY_DEVICE CommonMemoryDeviceHeader;
> UINT16 SocketIdentifier;
> UINT16 Reserved;
> // EFI_ACPI_6_4_PMTT_COMMON_MEMORY_DEVICE MemoryDeviceStructure[];
> } EFI_ACPI_6_4_PMTT_SOCKET_TYPE_DATA;
>
>
> ///
> /// Socket Type Data.
> ///
> typedef struct {
> EFI_ACPI_6_4_PMTT_COMMON_MEMORY_DEVICE CommonMemoryDeviceHeader;
> UINT16 SocketIdentifier;
> UINT16 Reserved;
> EFI_ACPI_6_4_PMTT_COMMON_MEMORY_DEVICE MemoryDeviceStructure[]
> }
This change might be okay. Both variants may be size (and
layout)-equivalent. See https://godbolt.org/z/364e4T4a7. You need to
check if e.g there's any padding after Reserved and before
MemoryDeviceStructure.
Basically make sure member offsets and sizes remain stable.
Thanks,
Pedro
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117455): https://edk2.groups.io/g/devel/message/117455
Mute This Topic: https://groups.io/mt/105305209/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
prev parent reply other threads:[~2024-04-05 7:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 9:27 [edk2-devel] [Question] using Flexible Array Member in Structure levi.yun
2024-04-03 16:17 ` Michael D Kinney
2024-04-05 6:43 ` levi.yun
2024-04-05 7:29 ` Pedro Falcato
2024-04-05 7:34 ` Pedro Falcato [this message]
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-list 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=CAKbZUD0fP8LZYfc8btaD0Ea53h3bjUuMharMfow6Tt+ZZpSs0A@mail.gmail.com \
--to=devel@edk2.groups.io \
/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