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 7D4F6AC177F for ; Tue, 22 Aug 2023 15:29:13 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=5dwmqViGha35zqv6yWrSCn7N8SbhbKLLvylQF17XNGw=; c=relaxed/simple; d=groups.io; h=From:Message-id:MIME-version:Subject:Date:In-reply-to:Cc:To:References:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-type; s=20140610; t=1692718152; v=1; b=OLac2vpPeWtNulM/PWXlV6l2sYOhRGLj5A99YTQWYT4FMmuXaSOQ2ewMZAZNyjEfRxkxqesn l4qDUmFpaZJlbUi3yZtAAW+IiNo/PSZ+syhkrQTLMOqhrGWFvtc5l3X0J//nhn7rosgCWlG5fxD fjahwAob2nesWOOK7yw89gwg= X-Received: by 127.0.0.2 with SMTP id m359YY7687511xWmnq3114Zg; Tue, 22 Aug 2023 08:29:12 -0700 X-Received: from rn-mailsvcp-mx-lapp03.apple.com (rn-mailsvcp-mx-lapp03.apple.com [17.179.253.24]) by mx.groups.io with SMTP id smtpd.web10.10864.1692718151667287541 for ; Tue, 22 Aug 2023 08:29:11 -0700 X-Received: from rn-mailsvcp-mta-lapp04.rno.apple.com (rn-mailsvcp-mta-lapp04.rno.apple.com [10.225.203.152]) by rn-mailsvcp-mx-lapp03.rno.apple.com (Oracle Communications Messaging Server 8.1.0.23.20230328 64bit (built Mar 28 2023)) with ESMTPS id <0RZS00TD3TONOC50@rn-mailsvcp-mx-lapp03.rno.apple.com> for devel@edk2.groups.io; Tue, 22 Aug 2023 08:29:11 -0700 (PDT) X-Proofpoint-ORIG-GUID: o087LjEqsj6V5qCkwOkp0ugCla_fu_Mn X-Proofpoint-GUID: o087LjEqsj6V5qCkwOkp0ugCla_fu_Mn X-Received: from rn-mailsvcp-policy-lapp01.rno.apple.com (rn-mailsvcp-policy-lapp01.rno.apple.com [17.179.253.18]) by rn-mailsvcp-mta-lapp04.rno.apple.com (Oracle Communications Messaging Server 8.1.0.23.20230328 64bit (built Mar 28 2023)) with ESMTPS id <0RZS00NPGTONP5J0@rn-mailsvcp-mta-lapp04.rno.apple.com>; Tue, 22 Aug 2023 08:29:11 -0700 (PDT) X-Received: from process_milters-daemon.rn-mailsvcp-policy-lapp01.rno.apple.com by rn-mailsvcp-policy-lapp01.rno.apple.com (Oracle Communications Messaging Server 8.1.0.22.20230228 64bit (built Feb 28 2023)) id <0RZS00500TIJVJ00@rn-mailsvcp-policy-lapp01.rno.apple.com>; Tue, 22 Aug 2023 08:29:11 -0700 (PDT) X-Va-A: X-Va-T-CD: b5a735853c2c90382d432773d336268d X-Va-E-CD: 0fa3bff0655c9c70858778c283cb6633 X-Va-R-CD: c72370b6fee179b1f3de43cc1cb94e38 X-Va-ID: 7114124d-0192-48ee-b9b5-d27cb1279899 X-Va-CD: 0 X-V-A: X-V-T-CD: b5a735853c2c90382d432773d336268d X-V-E-CD: 0fa3bff0655c9c70858778c283cb6633 X-V-R-CD: c72370b6fee179b1f3de43cc1cb94e38 X-V-ID: 44c73cf8-d388-42d0-b6c5-327a6c4cbf9c X-V-CD: 0 X-Received: from smtpclient.apple (unknown [17.11.97.175]) by rn-mailsvcp-policy-lapp01.rno.apple.com (Oracle Communications Messaging Server 8.1.0.22.20230228 64bit (built Feb 28 2023)) with ESMTPSA id <0RZS0064ATOILY00@rn-mailsvcp-policy-lapp01.rno.apple.com>; Tue, 22 Aug 2023 08:29:10 -0700 (PDT) From: "Andrew Fish via groups.io" Message-id: <7F57F8F5-9C13-4DD1-96CE-C3F7A33A1AFF@apple.com> MIME-version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: [edk2-devel] [PATCH] Use C99 flexible arrays Date: Tue, 22 Aug 2023 08:28:56 -0700 In-reply-to: <2096203168.82564.1692636984521@wsfrf1447.priv.atos.fr> Cc: "Yao, Jiewen" To: edk2-devel-groups-io , ehaouas@noos.fr References: <2096203168.82564.1692636984521@wsfrf1447.priv.atos.fr> 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 Reply-To: devel@edk2.groups.io,afish@apple.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: tlUQpfhKsTT2hlJKuenS0jsXx7686176AA= Content-type: multipart/alternative; boundary="Apple-Mail=_0305D079-5A0D-4024-AB70-C3A4148BB375" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=OLac2vpP; dmarc=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 --Apple-Mail=_0305D079-5A0D-4024-AB70-C3A4148BB375 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 My understanding is zero length arrays have not been legal C code since C89= . They may still function as a compiler extension.=20 struct foo { size_t len; char. Str[]0];=20 }; I seem to remember the reason we did not use the C99 flexible array members= is back in the day as Visual Studio 2003 did not have proper C99 support, = and did not support it.=20 struct foo { size_t len; char. Str[]];=20 }; I think the recommended C89 method for doing this is: struct foo { size_t len; char. Str[]1];=20 }; But that is not backwards compatible as the sizes are different.=20 So it is probably good long term to move to valid C99, but we should verify= we did not break anything.=20 Thanks, Andrew Fish > On Aug 21, 2023, at 9:56 AM, ehaouas wrote: >=20 > =E2=80=8C > Hi, >=20 > No, I didn't. > =20 > De : "Yao, Jiewen" > A : "devel@edk2.groups.io" ,"ehaouas@noos.fr" ,"Yao, Jiewen" > Envoy=C3=A9: lundi 21 Ao=C3=BBt 2023 16:35 > Objet : RE: [edk2-devel] [PATCH] Use C99 flexible arrays > =20 > Hi > This fix breaks the compatibility. >=20 > Have you tested all features that depends on this data structure? >=20 > Thank you > Yao, Jiewen >=20 > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of Elyes Haouas > > Sent: Sunday, August 20, 2023 8:07 PM > > To: devel@edk2.groups.io > > Cc: Elyes Haouas > > Subject: [edk2-devel] [PATCH] Use C99 flexible arrays > > > > Use C99 flexible arrays instead of older style of one-element or > > zero-length arrays. > > It allows the compiler to generate errors when the flexible array does > > not occur at the end in the structure. > > > > Signed-off-by: Elyes Haouas > > --- > > EmbeddedPkg/Include/fdt.h | 4 ++-- > > .../Library/FrameBufferBltLib/FrameBufferBltLib.c | 2 +- > > MdePkg/Include/IndustryStandard/IpmiNetFnApp.h | 8 ++++---- > > MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h | 4 ++-- > > MdePkg/Include/IndustryStandard/IpmiNetFnStorage.h | 6 +++--- > > MdePkg/Include/IndustryStandard/IpmiNetFnTransport.h | 8 ++++---- > > MdePkg/Include/IndustryStandard/PldmSmbiosTransfer.h | 8 ++++---- > > MdePkg/Include/IndustryStandard/TcgStorageCore.h | 6 +++--- > > MdePkg/Include/Protocol/NetworkInterfaceIdentifier.h | 2 +- > > MdePkg/Include/Protocol/NvdimmLabel.h | 2 +- > > UefiPayloadPkg/Include/Coreboot.h | 10 +++++----- > > 11 files changed, 30 insertions(+), 30 deletions(-) > > > > diff --git a/EmbeddedPkg/Include/fdt.h b/EmbeddedPkg/Include/fdt.h > > index 120dbc8bc6..f64695da5c 100644 > > --- a/EmbeddedPkg/Include/fdt.h > > +++ b/EmbeddedPkg/Include/fdt.h > > @@ -81,14 +81,14 @@ struct fdt_reserve_entry { > > > > > > struct fdt_node_header { > > > > fdt32_t tag; > > > > - char name[0]; > > > > + char name[]; > > > > }; > > > > > > > > struct fdt_property { > > > > fdt32_t tag; > > > > fdt32_t len; > > > > fdt32_t nameoff; > > > > - char data[0]; > > > > + char data[]; > > > > }; > > > > > > > > #endif /* !__ASSEMBLY */ > > > > diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c > > b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c > > index 432577bcfd..5fc5779e16 100644 > > --- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c > > +++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c > > @@ -24,7 +24,7 @@ struct FRAME_BUFFER_CONFIGURE { > > EFI_PIXEL_BITMASK PixelMasks; > > > > INT8 PixelShl[4]; // R-G-B-Rsvd > > > > INT8 PixelShr[4]; // R-G-B-Rsvd > > > > - UINT8 LineBuffer[0]; > > > > + UINT8 LineBuffer[]; > > > > }; > > > > > > > > CONST EFI_PIXEL_BITMASK mRgbPixelMasks =3D { > > > > diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnApp.h > > b/MdePkg/Include/IndustryStandard/IpmiNetFnApp.h > > index b6bc91f46c..b5174a5042 100644 > > --- a/MdePkg/Include/IndustryStandard/IpmiNetFnApp.h > > +++ b/MdePkg/Include/IndustryStandard/IpmiNetFnApp.h > > @@ -433,7 +433,7 @@ typedef union { > > typedef struct { > > > > UINT8 CompletionCode; > > > > IPMI_GET_MESSAGE_CHANNEL_NUMBER ChannelNumber; > > > > - UINT8 MessageData[0]; > > > > + UINT8 MessageData[]; > > > > } IPMI_GET_MESSAGE_RESPONSE; > > > > > > > > // > > > > @@ -457,12 +457,12 @@ typedef union { > > typedef struct { > > > > UINT8 CompletionCode; > > > > IPMI_SEND_MESSAGE_CHANNEL_NUMBER ChannelNumber; > > > > - UINT8 MessageData[0]; > > > > + UINT8 MessageData[]; > > > > } IPMI_SEND_MESSAGE_REQUEST; > > > > > > > > typedef struct { > > > > UINT8 CompletionCode; > > > > - UINT8 ResponseData[0]; > > > > + UINT8 ResponseData[]; > > > > } IPMI_SEND_MESSAGE_RESPONSE; > > > > > > > > // > > > > @@ -906,7 +906,7 @@ typedef union { > > typedef struct { > > > > IPMI_SET_USER_PASSWORD_USER_ID UserId; > > > > IPMI_SET_USER_PASSWORD_OPERATION Operation; > > > > - UINT8 PasswordData[0]; // 16 or 20 bytes, depending on the > > 'PasswordSize' field > > > > + UINT8 PasswordData[]; // 16 or 20 bytes, depending on the > > 'PasswordSize' field > > > > } IPMI_SET_USER_PASSWORD_REQUEST; > > > > > > > > // > > > > diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h > > b/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h > > index e3b8a62105..44024da69c 100644 > > --- a/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h > > +++ b/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h > > @@ -183,7 +183,7 @@ typedef union { > > > > > > typedef struct { > > > > IPMI_SET_BOOT_OPTIONS_PARAMETER_VALID ParameterValid; > > > > - UINT8 ParameterData[0]; > > > > + UINT8 ParameterData[]; > > > > } IPMI_SET_BOOT_OPTIONS_REQUEST; > > > > > > > > typedef struct { > > > > @@ -415,7 +415,7 @@ typedef struct { > > UINT8 CompletionCode; > > > > IPMI_GET_BOOT_OPTIONS_PARAMETER_VERSION ParameterVersion; > > > > IPMI_GET_BOOT_OPTIONS_PARAMETER_VALID ParameterValid; > > > > - UINT8 ParameterData[0]; > > > > + UINT8 ParameterData[]; > > > > } IPMI_GET_BOOT_OPTIONS_RESPONSE; > > > > > > > > // > > > > diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnStorage.h > > b/MdePkg/Include/IndustryStandard/IpmiNetFnStorage.h > > index 553a69a472..755bcb67e5 100644 > > --- a/MdePkg/Include/IndustryStandard/IpmiNetFnStorage.h > > +++ b/MdePkg/Include/IndustryStandard/IpmiNetFnStorage.h > > @@ -76,7 +76,7 @@ typedef struct { > > typedef struct { > > > > UINT8 CompletionCode; > > > > UINT8 CountReturned; > > > > - UINT8 Data[0]; > > > > + UINT8 Data[]; > > > > } IPMI_READ_FRU_DATA_RESPONSE; > > > > > > > > // > > > > @@ -95,7 +95,7 @@ typedef struct { > > typedef struct { > > > > UINT8 DeviceId; > > > > UINT16 InventoryOffset; > > > > - UINT8 Data[0]; > > > > + UINT8 Data[]; > > > > } IPMI_WRITE_FRU_DATA_REQUEST; > > > > > > > > typedef struct { > > > > @@ -594,7 +594,7 @@ typedef struct { > > UINT16 RecordId; > > > > UINT8 OffsetIntoRecord; > > > > UINT8 InProgress; > > > > - UINT8 RecordData[0]; > > > > + UINT8 RecordData[]; > > > > } IPMI_PARTIAL_ADD_SEL_ENTRY_REQUEST; > > > > > > > > typedef struct { > > > > diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnTransport.h > > b/MdePkg/Include/IndustryStandard/IpmiNetFnTransport.h > > index 2024c35f7f..273a162552 100644 > > --- a/MdePkg/Include/IndustryStandard/IpmiNetFnTransport.h > > +++ b/MdePkg/Include/IndustryStandard/IpmiNetFnTransport.h > > @@ -313,7 +313,7 @@ typedef union { > > typedef struct { > > > > IPMI_SET_LAN_CONFIG_CHANNEL_NUM ChannelNumber; > > > > UINT8 ParameterSelector; > > > > - UINT8 ParameterData[0]; > > > > + UINT8 ParameterData[]; > > > > } IPMI_SET_LAN_CONFIGURATION_PARAMETERS_COMMAND_REQUEST; > > > > > > > > // > > > > @@ -343,7 +343,7 @@ typedef struct { > > typedef struct { > > > > UINT8 CompletionCode; > > > > UINT8 ParameterRevision; > > > > - UINT8 ParameterData[0]; > > > > + UINT8 ParameterData[]; > > > > } IPMI_GET_LAN_CONFIGURATION_PARAMETERS_RESPONSE; > > > > > > > > // > > > > @@ -879,7 +879,7 @@ typedef union { > > typedef struct { > > > > IPMI_SET_SOL_CONFIG_PARAM_CHANNEL_NUM ChannelNumber; > > > > UINT8 ParameterSelector; > > > > - UINT8 ParameterData[0]; > > > > + UINT8 ParameterData[]; > > > > } IPMI_SET_SOL_CONFIGURATION_PARAMETERS_REQUEST; > > > > > > > > // > > > > @@ -909,7 +909,7 @@ typedef struct { > > typedef struct { > > > > UINT8 CompletionCode; > > > > UINT8 ParameterRevision; > > > > - UINT8 ParameterData[0]; > > > > + UINT8 ParameterData[]; > > > > } IPMI_GET_SOL_CONFIGURATION_PARAMETERS_RESPONSE; > > > > > > > > #pragma pack() > > > > diff --git a/MdePkg/Include/IndustryStandard/PldmSmbiosTransfer.h > > b/MdePkg/Include/IndustryStandard/PldmSmbiosTransfer.h > > index 9b7a5e838e..3e72812ea7 100644 > > --- a/MdePkg/Include/IndustryStandard/PldmSmbiosTransfer.h > > +++ b/MdePkg/Include/IndustryStandard/PldmSmbiosTransfer.h > > @@ -92,7 +92,7 @@ typedef struct { > > typedef struct { > > > > UINT32 NextDataTransferHandle; > > > > UINT8 TransferFlag; > > > > - UINT8 Table[0]; > > > > + UINT8 Table[]; > > > > } PLDM_GET_SMBIOS_STRUCTURE_TABLE_RESPONSE; > > > > > > > > typedef struct { > > > > @@ -106,7 +106,7 @@ typedef struct { > > typedef struct { > > > > UINT32 DataTransferHandle; > > > > UINT8 TransferFlag; > > > > - UINT8 Table[0]; > > > > + UINT8 Table[]; > > > > } PLDM_SET_SMBIOS_STRUCTURE_TABLE_REQUEST; > > > > > > > > typedef struct { > > > > @@ -143,7 +143,7 @@ typedef struct { > > typedef struct { > > > > UINT32 NextDataTransferHandle; > > > > UINT8 TransferFlag; > > > > - UINT8 Table[0]; > > > > + UINT8 Table[]; > > > > } PLDM_GET_SMBIOS_STRUCTURE_BY_TYPE_RESPONSE; > > > > > > > > typedef struct { > > > > @@ -171,7 +171,7 @@ typedef struct { > > typedef struct { > > > > UINT32 NextDataTransferHandle; > > > > UINT8 TransferFlag; > > > > - UINT8 Table[0]; > > > > + UINT8 Table[]; > > > > } PLDM_GET_SMBIOS_STRUCTURE_BY_HANDLE_RESPONSE; > > > > > > > > typedef struct { > > > > diff --git a/MdePkg/Include/IndustryStandard/TcgStorageCore.h > > b/MdePkg/Include/IndustryStandard/TcgStorageCore.h > > index 1fae7b6e84..7502e3d46c 100644 > > --- a/MdePkg/Include/IndustryStandard/TcgStorageCore.h > > +++ b/MdePkg/Include/IndustryStandard/TcgStorageCore.h > > @@ -38,7 +38,7 @@ typedef struct { > > UINT32 OutstandingDataBE; > > > > UINT32 MinTransferBE; > > > > UINT32 LengthBE; > > > > - UINT8 Payload[0]; > > > > + UINT8 Payload[]; > > > > } TCG_COM_PACKET; > > > > > > > > typedef struct { > > > > @@ -49,7 +49,7 @@ typedef struct { > > UINT16 AckTypeBE; > > > > UINT32 AcknowledgementBE; > > > > UINT32 LengthBE; > > > > - UINT8 Payload[0]; > > > > + UINT8 Payload[]; > > > > } TCG_PACKET; > > > > > > > > #define TCG_SUBPACKET_ALIGNMENT 4// 4-byte alignment per spec > > > > @@ -58,7 +58,7 @@ typedef struct { > > UINT8 ReservedBE[6]; > > > > UINT16 KindBE; > > > > UINT32 LengthBE; > > > > - UINT8 Payload[0]; > > > > + UINT8 Payload[]; > > > > } TCG_SUB_PACKET; > > > > > > > > #define SUBPACKET_KIND_DATA 0x0000 > > > > diff --git a/MdePkg/Include/Protocol/NetworkInterfaceIdentifier.h > > b/MdePkg/Include/Protocol/NetworkInterfaceIdentifier.h > > index 78acb4ddae..85d904ca9c 100644 > > --- a/MdePkg/Include/Protocol/NetworkInterfaceIdentifier.h > > +++ b/MdePkg/Include/Protocol/NetworkInterfaceIdentifier.h > > @@ -101,7 +101,7 @@ struct undiconfig_table { > > struct { > > > > VOID *NII_InterfacePointer; ///< Pointer to the NII interface structure= . > > > > VOID *DevicePathPointer; ///< Pointer to the device path for this NIC. > > > > - } NII_entry[1]; > > > > + } NII_entry[]; > > > > }; > > > > > > > > extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid; > > > > diff --git a/MdePkg/Include/Protocol/NvdimmLabel.h > > b/MdePkg/Include/Protocol/NvdimmLabel.h > > index e46999a3ab..91a9b675f9 100644 > > --- a/MdePkg/Include/Protocol/NvdimmLabel.h > > +++ b/MdePkg/Include/Protocol/NvdimmLabel.h > > @@ -244,7 +244,7 @@ typedef struct { > > /// > > > > /// Array size is 1 if EFI_NVDIMM_LABEL_FLAGS_LOCAL is set indicating a= Local > > Namespaces. > > > > /// > > > > - EFI_NVDIMM_LABEL_SET_COOKIE_MAP Mapping[0]; > > > > + EFI_NVDIMM_LABEL_SET_COOKIE_MAP Mapping[]; > > > > } EFI_NVDIMM_LABEL_SET_COOKIE_INFO; > > > > > > > > /** > > > > diff --git a/UefiPayloadPkg/Include/Coreboot.h > > b/UefiPayloadPkg/Include/Coreboot.h > > index 2d454f7c89..a53ede390c 100644 > > --- a/UefiPayloadPkg/Include/Coreboot.h > > +++ b/UefiPayloadPkg/Include/Coreboot.h > > @@ -59,7 +59,7 @@ struct cbmem_root { > > UINT32 num_entries; > > > > UINT32 locked; > > > > UINT32 size; > > > > - struct cbmem_entry entries[0]; > > > > + struct cbmem_entry entries[]; > > > > }; > > > > > > > > struct imd_entry { > > > > @@ -75,7 +75,7 @@ struct imd_root { > > UINT32 flags; > > > > UINT32 entry_align; > > > > UINT32 max_offset; > > > > - struct imd_entry entries[0]; > > > > + struct imd_entry entries[]; > > > > }; > > > > > > > > struct cbuint64 { > > > > @@ -119,7 +119,7 @@ struct cb_memory_range { > > struct cb_memory { > > > > UINT32 tag; > > > > UINT32 size; > > > > - struct cb_memory_range map[0]; > > > > + struct cb_memory_range map[]; > > > > }; > > > > > > > > #define CB_TAG_MAINBOARD 0x0003 > > > > @@ -129,7 +129,7 @@ struct cb_mainboard { > > UINT32 size; > > > > UINT8 vendor_idx; > > > > UINT8 part_number_idx; > > > > - UINT8 strings[0]; > > > > + UINT8 strings[]; > > > > }; > > > > > > > > #define CB_TAG_VERSION 0x0004 > > > > @@ -146,7 +146,7 @@ struct cb_mainboard { > > struct cb_string { > > > > UINT32 tag; > > > > UINT32 size; > > > > - UINT8 string[0]; > > > > + UINT8 string[]; > > > > }; > > > > > > > > #define CB_TAG_SERIAL 0x000f > > > > -- > > 2.40.1 > > > > > > > > -=3D-=3D-=3D-=3D-=3D-=3D > > Groups.io Links: You receive all messages sent to this group. > > View/Reply Online (#107898): https://edk2.groups.io/g/devel/message/107= 898 > > Mute This Topic: https://groups.io/mt/100861513/1772286 > > Group Owner: devel+owner@edk2.groups.io > > Unsubscribe: https://edk2.groups.io/g/devel/unsub [jiewen.yao@intel.com= ] > > -=3D-=3D-=3D-=3D-=3D-=3D > > > =20 >=20 -=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 (#107951): https://edk2.groups.io/g/devel/message/107951 Mute This Topic: https://groups.io/mt/100861513/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --Apple-Mail=_0305D079-5A0D-4024-AB70-C3A4148BB375 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 My understanding is zero length a= rrays have not been legal C code since C89. They may still function as a co= mpiler extension. 

struct foo {
  si= ze_t len;
  char. Str[]0]; 
};

=
I seem to remember the reason we did not use the C99 flexible ar= ray members is back in the day as Visual Studio 2003 did not have proper C9= 9 support, and did not support it. 

stru= ct foo {
  size_t len;
  char. Str[]]; <= /div>
};

I think the recommended C89 method fo= r doing this is:

struct foo {
 = ; size_t len;
  char. Str[]1]; 
};

But that is not backwards compatible as the sizes are = different. 

So it is probably good long term = to move to valid C99, but we should verify we did not break anything. =

Thanks,

Andrew Fish


On Aug 21, 2023, at= 9:56 AM, ehaouas <ehaouas@noos.fr> wrote:

=E2=80=8C
Hi,

No, I didn't.
 
De : = "Yao, Jiewen"
A : "devel@edk2.groups.io" ,"ehaouas@noos.fr" ,"Yao, Jiewen"
Envoy=C3=A9: lundi 21 Ao=C3=BBt 2023 16:35
Objet : RE: [edk2-devel] [PATCH] Use C99 flexible arrays
 
Hi
This fix breaks the compatibility.

Have you tested all features that depends on this data structure?

Thank you
Yao, Jiewen

> -----Original Message-----
> From: devel@edk2.groups.io On Behalf Of Elyes Haouas
> Sent: Sunday, August 20, 2023 8:07 PM
> To: devel@edk2.groups.io
> Cc: Elyes Haouas
> Subject: [edk2-devel] [PATCH] Use C99 flexible arrays
>
> Use C99 flexible arrays instead of older style of one-element or
> zero-length arrays.
> It allows the compiler to generate errors when the flexible array does=
> not occur at the end in the structure.
>
> Signed-off-by: Elyes Haouas
> ---
> EmbeddedPkg/Include/fdt.h | 4 ++--
> .../Library/FrameBufferBltLib/FrameBufferBltLib.c | 2 +-
> MdePkg/Include/IndustryStandard/IpmiNetFnApp.h | 8 ++++----
> MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h | 4 ++--
> MdePkg/Include/IndustryStandard/IpmiNetFnStorage.h | 6 +++---
> MdePkg/Include/IndustryStandard/IpmiNetFnTransport.h | 8 ++++----
> MdePkg/Include/IndustryStandard/PldmSmbiosTransfer.h | 8 ++++----
> MdePkg/Include/IndustryStandard/TcgStorageCore.h | 6 +++---
> MdePkg/Include/Protocol/NetworkInterfaceIdentifier.h | 2 +-
> MdePkg/Include/Protocol/NvdimmLabel.h | 2 +-
> UefiPayloadPkg/Include/Coreboot.h | 10 +++++-----
> 11 files changed, 30 insertions(+), 30 deletions(-)
>
> diff --git a/EmbeddedPkg/Include/fdt.h b/EmbeddedPkg/Include/fdt.h
> index 120dbc8bc6..f64695da5c 100644
> --- a/EmbeddedPkg/Include/fdt.h
> +++ b/EmbeddedPkg/Include/fdt.h
> @@ -81,14 +81,14 @@ struct fdt_reserve_entry {
>
>
> struct fdt_node_header {
>
> fdt32_t tag;
>
> - char name[0];
>
> + char name[];
>
> };
>
>
>
> struct fdt_property {
>
> fdt32_t tag;
>
> fdt32_t len;
>
> fdt32_t nameoff;
>
> - char data[0];
>
> + char data[];
>
> };
>
>
>
> #endif /* !__ASSEMBLY */
>
> diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.= c
> b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
> index 432577bcfd..5fc5779e16 100644
> --- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
> +++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
> @@ -24,7 +24,7 @@ struct FRAME_BUFFER_CONFIGURE {
> EFI_PIXEL_BITMASK PixelMasks;
>
> INT8 PixelShl[4]; // R-G-B-Rsvd
>
> INT8 PixelShr[4]; // R-G-B-Rsvd
>
> - UINT8 LineBuffer[0];
>
> + UINT8 LineBuffer[];
>
> };
>
>
>
> CONST EFI_PIXEL_BITMASK mRgbPixelMasks =3D {
>
> diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnApp.h
> b/MdePkg/Include/IndustryStandard/IpmiNetFnApp.h
> index b6bc91f46c..b5174a5042 100644
> --- a/MdePkg/Include/IndustryStandard/IpmiNetFnApp.h
> +++ b/MdePkg/Include/IndustryStandard/IpmiNetFnApp.h
> @@ -433,7 +433,7 @@ typedef union {
> typedef struct {
>
> UINT8 CompletionCode;
>
> IPMI_GET_MESSAGE_CHANNEL_NUMBER ChannelNumber;
>
> - UINT8 MessageData[0];
>
> + UINT8 MessageData[];
>
> } IPMI_GET_MESSAGE_RESPONSE;
>
>
>
> //
>
> @@ -457,12 +457,12 @@ typedef union {
> typedef struct {
>
> UINT8 CompletionCode;
>
> IPMI_SEND_MESSAGE_CHANNEL_NUMBER ChannelNumber;
>
> - UINT8 MessageData[0];
>
> + UINT8 MessageData[];
>
> } IPMI_SEND_MESSAGE_REQUEST;
>
>
>
> typedef struct {
>
> UINT8 CompletionCode;
>
> - UINT8 ResponseData[0];
>
> + UINT8 ResponseData[];
>
> } IPMI_SEND_MESSAGE_RESPONSE;
>
>
>
> //
>
> @@ -906,7 +906,7 @@ typedef union {
> typedef struct {
>
> IPMI_SET_USER_PASSWORD_USER_ID UserId;
>
> IPMI_SET_USER_PASSWORD_OPERATION Operation;
>
> - UINT8 PasswordData[0]; // 16 or 20 bytes, depending on the
> 'PasswordSize' field
>
> + UINT8 PasswordData[]; // 16 or 20 bytes, depending on the
> 'PasswordSize' field
>
> } IPMI_SET_USER_PASSWORD_REQUEST;
>
>
>
> //
>
> diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h
> b/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h
> index e3b8a62105..44024da69c 100644
> --- a/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h
> +++ b/MdePkg/Include/IndustryStandard/IpmiNetFnChassis.h
> @@ -183,7 +183,7 @@ typedef union {
>
>
> typedef struct {
>
> IPMI_SET_BOOT_OPTIONS_PARAMETER_VALID ParameterValid;
>
> - UINT8 ParameterData[0];
>
> + UINT8 ParameterData[];
>
> } IPMI_SET_BOOT_OPTIONS_REQUEST;
>
>
>
> typedef struct {
>
> @@ -415,7 +415,7 @@ typedef struct {
> UINT8 CompletionCode;
>
> IPMI_GET_BOOT_OPTIONS_PARAMETER_VERSION ParameterVersion;
>
> IPMI_GET_BOOT_OPTIONS_PARAMETER_VALID ParameterValid;
>
> - UINT8 ParameterData[0];
>
> + UINT8 ParameterData[];
>
> } IPMI_GET_BOOT_OPTIONS_RESPONSE;
>
>
>
> //
>
> diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnStorage.h
> b/MdePkg/Include/IndustryStandard/IpmiNetFnStorage.h
> index 553a69a472..755bcb67e5 100644
> --- a/MdePkg/Include/IndustryStandard/IpmiNetFnStorage.h
> +++ b/MdePkg/Include/IndustryStandard/IpmiNetFnStorage.h
> @@ -76,7 +76,7 @@ typedef struct {
> typedef struct {
>
> UINT8 CompletionCode;
>
> UINT8 CountReturned;
>
> - UINT8 Data[0];
>
> + UINT8 Data[];
>
> } IPMI_READ_FRU_DATA_RESPONSE;
>
>
>
> //
>
> @@ -95,7 +95,7 @@ typedef struct {
> typedef struct {
>
> UINT8 DeviceId;
>
> UINT16 InventoryOffset;
>
> - UINT8 Data[0];
>
> + UINT8 Data[];
>
> } IPMI_WRITE_FRU_DATA_REQUEST;
>
>
>
> typedef struct {
>
> @@ -594,7 +594,7 @@ typedef struct {
> UINT16 RecordId;
>
> UINT8 OffsetIntoRecord;
>
> UINT8 InProgress;
>
> - UINT8 RecordData[0];
>
> + UINT8 RecordData[];
>
> } IPMI_PARTIAL_ADD_SEL_ENTRY_REQUEST;
>
>
>
> typedef struct {
>
> diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnTransport.h
> b/MdePkg/Include/IndustryStandard/IpmiNetFnTransport.h
> index 2024c35f7f..273a162552 100644
> --- a/MdePkg/Include/IndustryStandard/IpmiNetFnTransport.h
> +++ b/MdePkg/Include/IndustryStandard/IpmiNetFnTransport.h
> @@ -313,7 +313,7 @@ typedef union {
> typedef struct {
>
> IPMI_SET_LAN_CONFIG_CHANNEL_NUM ChannelNumber;
>
> UINT8 ParameterSelector;
>
> - UINT8 ParameterData[0];
>
> + UINT8 ParameterData[];
>
> } IPMI_SET_LAN_CONFIGURATION_PARAMETERS_COMMAND_REQUEST;
>
>
>
> //
>
> @@ -343,7 +343,7 @@ typedef struct {
> typedef struct {
>
> UINT8 CompletionCode;
>
> UINT8 ParameterRevision;
>
> - UINT8 ParameterData[0];
>
> + UINT8 ParameterData[];
>
> } IPMI_GET_LAN_CONFIGURATION_PARAMETERS_RESPONSE;
>
>
>
> //
>
> @@ -879,7 +879,7 @@ typedef union {
> typedef struct {
>
> IPMI_SET_SOL_CONFIG_PARAM_CHANNEL_NUM ChannelNumber;
>
> UINT8 ParameterSelector;
>
> - UINT8 ParameterData[0];
>
> + UINT8 ParameterData[];
>
> } IPMI_SET_SOL_CONFIGURATION_PARAMETERS_REQUEST;
>
>
>
> //
>
> @@ -909,7 +909,7 @@ typedef struct {
> typedef struct {
>
> UINT8 CompletionCode;
>
> UINT8 ParameterRevision;
>
> - UINT8 ParameterData[0];
>
> + UINT8 ParameterData[];
>
> } IPMI_GET_SOL_CONFIGURATION_PARAMETERS_RESPONSE;
>
>
>
> #pragma pack()
>
> diff --git a/MdePkg/Include/IndustryStandard/PldmSmbiosTransfer.h
> b/MdePkg/Include/IndustryStandard/PldmSmbiosTransfer.h
> index 9b7a5e838e..3e72812ea7 100644
> --- a/MdePkg/Include/IndustryStandard/PldmSmbiosTransfer.h
> +++ b/MdePkg/Include/IndustryStandard/PldmSmbiosTransfer.h
> @@ -92,7 +92,7 @@ typedef struct {
> typedef struct {
>
> UINT32 NextDataTransferHandle;
>
> UINT8 TransferFlag;
>
> - UINT8 Table[0];
>
> + UINT8 Table[];
>
> } PLDM_GET_SMBIOS_STRUCTURE_TABLE_RESPONSE;
>
>
>
> typedef struct {
>
> @@ -106,7 +106,7 @@ typedef struct {
> typedef struct {
>
> UINT32 DataTransferHandle;
>
> UINT8 TransferFlag;
>
> - UINT8 Table[0];
>
> + UINT8 Table[];
>
> } PLDM_SET_SMBIOS_STRUCTURE_TABLE_REQUEST;
>
>
>
> typedef struct {
>
> @@ -143,7 +143,7 @@ typedef struct {
> typedef struct {
>
> UINT32 NextDataTransferHandle;
>
> UINT8 TransferFlag;
>
> - UINT8 Table[0];
>
> + UINT8 Table[];
>
> } PLDM_GET_SMBIOS_STRUCTURE_BY_TYPE_RESPONSE;
>
>
>
> typedef struct {
>
> @@ -171,7 +171,7 @@ typedef struct {
> typedef struct {
>
> UINT32 NextDataTransferHandle;
>
> UINT8 TransferFlag;
>
> - UINT8 Table[0];
>
> + UINT8 Table[];
>
> } PLDM_GET_SMBIOS_STRUCTURE_BY_HANDLE_RESPONSE;
>
>
>
> typedef struct {
>
> diff --git a/MdePkg/Include/IndustryStandard/TcgStorageCore.h
> b/MdePkg/Include/IndustryStandard/TcgStorageCore.h
> index 1fae7b6e84..7502e3d46c 100644
> --- a/MdePkg/Include/IndustryStandard/TcgStorageCore.h
> +++ b/MdePkg/Include/IndustryStandard/TcgStorageCore.h
> @@ -38,7 +38,7 @@ typedef struct {
> UINT32 OutstandingDataBE;
>
> UINT32 MinTransferBE;
>
> UINT32 LengthBE;
>
> - UINT8 Payload[0];
>
> + UINT8 Payload[];
>
> } TCG_COM_PACKET;
>
>
>
> typedef struct {
>
> @@ -49,7 +49,7 @@ typedef struct {
> UINT16 AckTypeBE;
>
> UINT32 AcknowledgementBE;
>
> UINT32 LengthBE;
>
> - UINT8 Payload[0];
>
> + UINT8 Payload[];
>
> } TCG_PACKET;
>
>
>
> #define TCG_SUBPACKET_ALIGNMENT 4// 4-byte alignment per spec
>
> @@ -58,7 +58,7 @@ typedef struct {
> UINT8 ReservedBE[6];
>
> UINT16 KindBE;
>
> UINT32 LengthBE;
>
> - UINT8 Payload[0];
>
> + UINT8 Payload[];
>
> } TCG_SUB_PACKET;
>
>
>
> #define SUBPACKET_KIND_DATA 0x0000
>
> diff --git a/MdePkg/Include/Protocol/NetworkInterfaceIdentifier.h
> b/MdePkg/Include/Protocol/NetworkInterfaceIdentifier.h
> index 78acb4ddae..85d904ca9c 100644
> --- a/MdePkg/Include/Protocol/NetworkInterfaceIdentifier.h
> +++ b/MdePkg/Include/Protocol/NetworkInterfaceIdentifier.h
> @@ -101,7 +101,7 @@ struct undiconfig_table {
> struct {
>
> VOID *NII_InterfacePointer; ///< Pointer to the NII interface struc= ture.
>
> VOID *DevicePathPointer; ///< Pointer to the device path for this N= IC.
>
> - } NII_entry[1];
>
> + } NII_entry[];
>
> };
>
>
>
> extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid;
>
> diff --git a/MdePkg/Include/Protocol/NvdimmLabel.h
> b/MdePkg/Include/Protocol/NvdimmLabel.h
> index e46999a3ab..91a9b675f9 100644
> --- a/MdePkg/Include/Protocol/NvdimmLabel.h
> +++ b/MdePkg/Include/Protocol/NvdimmLabel.h
> @@ -244,7 +244,7 @@ typedef struct {
> ///
>
> /// Array size is 1 if EFI_NVDIMM_LABEL_FLAGS_LOCAL is set indicating = a Local
> Namespaces.
>
> ///
>
> - EFI_NVDIMM_LABEL_SET_COOKIE_MAP Mapping[0];
>
> + EFI_NVDIMM_LABEL_SET_COOKIE_MAP Mapping[];
>
> } EFI_NVDIMM_LABEL_SET_COOKIE_INFO;
>
>
>
> /**
>
> diff --git a/UefiPayloadPkg/Include/Coreboot.h
> b/UefiPayloadPkg/Include/Coreboot.h
> index 2d454f7c89..a53ede390c 100644
> --- a/UefiPayloadPkg/Include/Coreboot.h
> +++ b/UefiPayloadPkg/Include/Coreboot.h
> @@ -59,7 +59,7 @@ struct cbmem_root {
> UINT32 num_entries;
>
> UINT32 locked;
>
> UINT32 size;
>
> - struct cbmem_entry entries[0];
>
> + struct cbmem_entry entries[];
>
> };
>
>
>
> struct imd_entry {
>
> @@ -75,7 +75,7 @@ struct imd_root {
> UINT32 flags;
>
> UINT32 entry_align;
>
> UINT32 max_offset;
>
> - struct imd_entry entries[0];
>
> + struct imd_entry entries[];
>
> };
>
>
>
> struct cbuint64 {
>
> @@ -119,7 +119,7 @@ struct cb_memory_range {
> struct cb_memory {
>
> UINT32 tag;
>
> UINT32 size;
>
> - struct cb_memory_range map[0];
>
> + struct cb_memory_range map[];
>
> };
>
>
>
> #define CB_TAG_MAINBOARD 0x0003
>
> @@ -129,7 +129,7 @@ struct cb_mainboard {
> UINT32 size;
>
> UINT8 vendor_idx;
>
> UINT8 part_number_idx;
>
> - UINT8 strings[0];
>
> + UINT8 strings[];
>
> };
>
>
>
> #define CB_TAG_VERSION 0x0004
>
> @@ -146,7 +146,7 @@ struct cb_mainboard {
> struct cb_string {
>
> UINT32 tag;
>
> UINT32 size;
>
> - UINT8 string[0];
>
> + UINT8 string[];
>
> };
>
>
>
> #define CB_TAG_SERIAL 0x000f
>
> --
> 2.40.1
>
>
>
> -=3D-=3D-=3D-=3D-=3D-=3D
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#107898): https://edk2.groups.io/g/devel/message/10= 7898
> Mute This Topic: https://groups.io/mt/100861513/1772286
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [jiewen.yao@intel.co= m]
> -=3D-=3D-=3D-=3D-=3D-=3D
>
 

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#107951) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--Apple-Mail=_0305D079-5A0D-4024-AB70-C3A4148BB375--