public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Elyes Haouas <ehaouas@noos.fr>
To: devel@edk2.groups.io
Cc: Elyes Haouas <ehaouas@noos.fr>
Subject: [edk2-devel] [PATCH 2/4] MdePkg/Include: Use C99 flexible arrays
Date: Thu, 24 Aug 2023 07:42:12 +0200	[thread overview]
Message-ID: <20230824054214.2839-2-ehaouas@noos.fr> (raw)
In-Reply-To: <20230824054214.2839-1-ehaouas@noos.fr>

One-element or zero-length arrays have been deprecated since
last millennium.
Use C99 flexible arrays instead, 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 <ehaouas@noos.fr>
---
 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 +-
 8 files changed, 22 insertions(+), 22 deletions(-)

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;
 
 /**
-- 
2.40.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108004): https://edk2.groups.io/g/devel/message/108004
Mute This Topic: https://groups.io/mt/100935950/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-08-24 14:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24  5:42 [edk2-devel] [PATCH 1/4] EmbeddedPkg: Use C99 flexible arrays Elyes Haouas
2023-08-24  5:42 ` Elyes Haouas [this message]
2023-08-24  5:42 ` [edk2-devel] [PATCH 3/4] MdeModulePkg/Library/FrameBufferBltLib: " Elyes Haouas
2023-08-24  5:42 ` [edk2-devel] [PATCH 4/4] UefiPayloadPkg: " Elyes Haouas

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=20230824054214.2839-2-ehaouas@noos.fr \
    --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