I agree that flexible array members are a good way to define this. The consumer needs to allocate extra space for the flexible array member.
If the size of the device path is known, then the allocation can be the exact size needed. sizeof(REST_EX_SERVICE_DEVICE_PATH_DATA) + DevicePathSize(DevicePath) Mike > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Pedro > Falcato > Sent: Friday, May 5, 2023 3:57 PM > To: devel@edk2.groups.io; minhnguy...@os.amperecomputing.com > Cc: patc...@amperecomputing.com; abner.ch...@amd.com; > nick...@nvidia.com; ig...@ami.com; n...@os.amperecomputing.com; > tinhngu...@os.amperecomputing.com; Vu Nguyen > <vungu...@os.amperecomputing.com>; Nick Ramirez > <nrami...@nvidia.com> > Subject: Re: [edk2-devel] [PATCH V3 5/5] RedfishPkg: Fix compile issue on > Linux > > On Fri, May 5, 2023 at 6:12 PM Minh Nguyen via groups.io > <minhnguyen1=os.amperecomputing....@groups.io> wrote: > > > > From: Vu Nguyen <vungu...@os.amperecomputing.com> > > > > It requires a fixed size array to store the content of device path PCD. > > Add the array size to solve this issue. > > > > Signed-off-by: Minh Nguyen <minhnguy...@os.amperecomputing.com> > > Cc: Abner Chang <abner.ch...@amd.com> > > Cc: Igor Kulchytskyy <ig...@ami.com> > > Cc: Nick Ramirez <nrami...@nvidia.com> > > Reviewed-by: Abner Chang <abner.ch...@amd.com> > > --- > > RedfishPkg/Include/Pcd/RestExServiceDevicePath.h | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h > b/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h > > index 91b1198297c2..57fc199f61f2 100644 > > --- a/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h > > +++ b/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h > > @@ -4,6 +4,7 @@ > > > > Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> > > (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> > > + Copyright (c) 2023, Ampere Computing LLC. All rights reserved.<BR> > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > @@ -14,6 +15,8 @@ > > > > #include <Protocol/DevicePath.h> > > > > +#define MAX_DEVICE_PATH_NODE 40 > > + > > typedef enum { > > DEVICE_PATH_MATCH_MAC_NODE = 1, > > DEVICE_PATH_MATCH_PCI_NODE = 2, > > @@ -32,7 +35,7 @@ typedef struct { > > // > 0x03,0x0b,0x25,0x00,0x00,0x50,0x56,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00 > ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 > 0,0x00,0x00,0x00,0x00,0x00,0x00,0x01, > > // 0x7f,0xff,0x04,0x00} > > // > > - EFI_DEVICE_PATH_PROTOCOL DevicePath[]; > > + EFI_DEVICE_PATH_PROTOCOL DevicePath[MAX_DEVICE_PATH_NODE]; > > } REST_EX_SERVICE_DEVICE_PATH_DATA; > > This doesn't work (changes the meaning) and may possibly break ABI. > > What error do you get? What compiler? > > C99 flexible array members have been well defined and well supported > for maybe 20 years in GCC (https://godbolt.org/z/9qxKar4f6) > > -- > Pedro > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#104163): https://edk2.groups.io/g/devel/message/104163 Mute This Topic: https://groups.io/mt/98710278/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-