From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id CBDC094130F for ; Fri, 5 Apr 2024 07:35:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=8ihd9m7CC/CKh/PF8hYsqYvEPAZTlh7PwdbWRkIEE3A=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20240206; t=1712302509; v=1; b=4RAzR/BzdxR05oGZ4l8/cZKnnMEkiBl4LPPvXRKvYwjqwWqxE337mygokB7R2VtaZNpXL+wD OHuizEkO/qdQCqusseHa0Ppn8qWbWlRIRnBPk5AvV9vhiuEHqIk8o36BqESh0o7uTKb/wbUG/g8 BYGbCK/kt2TuE+l7hA7VFUa8Uzdig4eXB7YAY7WYaA3MmFm4rA7PjEwWl0iWwWByjlNwWynTaiz lmE7990ZvGa4rnIQ8kxPEoRfp1QVTGDlMrKbCAX2afBDblDqhk2KgCBGuPWwc8ILU8L9kBZpKJ2 0FDVrGDIU3UkazwK6KOemrsMEXADvbQ3oZlywzao9WOyA== X-Received: by 127.0.0.2 with SMTP id VCKiYY7687511xk0OXCvyrX3; Fri, 05 Apr 2024 00:35:09 -0700 X-Received: from mail-vs1-f50.google.com (mail-vs1-f50.google.com [209.85.217.50]) by mx.groups.io with SMTP id smtpd.web11.5794.1712302508722476365 for ; Fri, 05 Apr 2024 00:35:08 -0700 X-Received: by mail-vs1-f50.google.com with SMTP id ada2fe7eead31-479d6a85be8so246015137.3 for ; Fri, 05 Apr 2024 00:35:08 -0700 (PDT) X-Gm-Message-State: QDcfHGlxq5Kh9bX3mE6V7Rdgx7686176AA= X-Google-Smtp-Source: AGHT+IEQGDbm7xWnCxRtwGUoAwkS2K+SN8rnTGslq3jFEmYhKVe6c/MGW4q8IfOW9NEZRgMiUTubN4FG0/oTHa1712c= X-Received: by 2002:a05:6102:1621:b0:479:dd02:919a with SMTP id cu33-20020a056102162100b00479dd02919amr854038vsb.29.1712302507554; Fri, 05 Apr 2024 00:35:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Pedro Falcato" Date: Fri, 5 Apr 2024 08:34:56 +0100 Message-ID: Subject: Re: [edk2-devel] [Question] using Flexible Array Member in Structure. To: devel@edk2.groups.io, yeoreum.yun@arm.com Cc: "nd@arm.com" , "sami.mujawar@arm.com" Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Fri, 05 Apr 2024 00:35:08 -0700 Resent-From: pedro.falcato@gmail.com Reply-To: devel@edk2.groups.io,pedro.falcato@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="4RAzR/Bz"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Wed, Apr 3, 2024 at 10:27=E2=80=AFAM levi.yun wrot= e: > > 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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-