From: Minh Nguyen <minhnguyen1@amperemail.onmicrosoft.com>
To: Pedro Falcato <pedro.falcato@gmail.com>,
devel@edk2.groups.io, minhnguyen1@os.amperecomputing.com
Cc: patches@amperecomputing.com, abner.chang@amd.com,
nicklew@nvidia.com, igork@ami.com, nhi@os.amperecomputing.com,
tinhnguyen@os.amperecomputing.com,
Vu Nguyen <vunguyen@os.amperecomputing.com>,
Nick Ramirez <nramirez@nvidia.com>
Subject: Re: [edk2-devel] [PATCH V3 5/5] RedfishPkg: Fix compile issue on Linux
Date: Sun, 7 May 2023 12:39:23 +0700 [thread overview]
Message-ID: <d6a6e209-7a5a-30cc-3202-ea4643ade21f@amperemail.onmicrosoft.com> (raw)
In-Reply-To: <CAKbZUD3hEaGaUKp2etN4E3dPqFktoPHcTeWN1WcRm3DJSs9Aug@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5069 bytes --]
Hi Pedro,
Firstly, thanks for your comments, let me explain.
- "C99 flexible array members have been well defined and well supported
for maybe 20 years in GCC (https://godbolt.org/z/9qxKar4f6)" => *Yes, I
agree and there's no**
**comment from my side* *but this is completely different with current
issue, why? Please see the bellow**
**explanation.*
- When we define the PCD to map with any structure in .dec file,
BaseTools will gen /*PcdValueInit.c*/.
In this file, there're a lot of using
"/*__FIELD_SIZE(REST_EX_SERVICE_DEVICE_PATH_DATA, DevicePath);*/"
and this is the definiton of this macro "/*#define __FIELD_SIZE(TYPE,
Field) (sizeof((TYPE *)0)->Field)*/".
When using
"/*__STATIC_ASSERT((__FIELD_SIZE(REST_EX_SERVICE_DEVICE_PATH_DATA,
DevicePath) >= 3) || *//*
*//*(__FIELD_SIZE(REST_EX_SERVICE_DEVICE_PATH_DATA, DevicePath) == 0),
"Input buffer exceeds the buffer array");*/",
"/*(sizeof((TYPE *)0)->Field*/" will be an error (_*error: invalid
application of ‘sizeof’ to incomplete type *__*
*__*EFI_DEVICE_PATH_PROTOCOL[]*_) => will cause error on
"__STATIC_ASSERT" because _Static_assert requires its first parameter
to be a constant expression => the error message when compile this code
is "_*Line 257 Value {0x03,0x0b,0x25,0x00,0x00,0x1b,*__*
*__*0x21,0xdc,0x35,0xb0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,*__*
*__*0x00,0x00,0x00,0x00,0x00,0x01,0x7f,0xff,0x04,0x00}:293:19: error:
expression in static assertion is not an integer*_"
- An other demonstation on other platforms in this behavior: you can
check at
*edk2-platforms/Features/Intel/SystemInformation/SmbiosFeaturePkg/SmbiosFeaturePkg.dec*.
/*gSmbiosFeaturePkgTokenSpaceGuid.PcdSmbiosType0BiosInformation|{0x0}|SMBIOS_TABLE_TYPE0|0xD0000001
{*//*
*//* <HeaderFiles>*//*
*//* IndustryStandard/SmBios.h*//*
*//* <Packages>*//*
*//* MdePkg/MdePkg.dec*//*
*//*SystemInformation/SmbiosFeaturePkg/SmbiosFeaturePkg.dec*//*
*//* }*/
/*gSmbiosFeaturePkgTokenSpaceGuid.PcdSmbiosType0BiosInformation.BIOSCharacteristicsExtensionBytes[0]|0x33*//*
*//*gSmbiosFeaturePkgTokenSpaceGuid.PcdSmbiosType0BiosInformation.BIOSCharacteristicsExtensionBytes[1]|0x0F*/
This is the declaration to map PcdSmbiosType0BiosInformation with
SMBIOS_TABLE_TYPE0 structure and
the declaration of BIOSCharacteristicsExtensionBytes is "*UINT8
BIOSCharacteristicsExtensionBytes[2];*". If
we remove the number of elements (2) to flexible array, we will see the
same error like "_*Index of BIOSCharacteristicsExtensionBytes[0]:361:19:
*__*
*__*error: expression in static assertion is not an integer*_".
=> Conclusion: This is not problem on compiler, it just comes from the
way BasTools gen PcdValueInit.c
and define macros for this case (map PCD structure to any structure). I
hope it satisfy your concerns.
Thanks,
Minh Nguyen.
On 5/6/2023 5:57 AM, Pedro Falcato wrote:
> On Fri, May 5, 2023 at 6:12 PM Minh Nguyen via groups.io
> <minhnguyen1=os.amperecomputing.com@groups.io> wrote:
>> From: Vu Nguyen<vunguyen@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<minhnguyen1@os.amperecomputing.com>
>> Cc: Abner Chang<abner.chang@amd.com>
>> Cc: Igor Kulchytskyy<igork@ami.com>
>> Cc: Nick Ramirez<nramirez@nvidia.com>
>> Reviewed-by: Abner Chang<Abner.Chang@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,0x00,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)
>
[-- Attachment #2: Type: text/html, Size: 7403 bytes --]
next prev parent reply other threads:[~2023-05-07 5:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 3:58 [PATCH V3 0/5] Adding necessary changes for RedfishPkg Minh Nguyen
2023-05-05 3:58 ` [PATCH V3 1/5] RedfishPkg: Correct variable type to prevent memory corruption Minh Nguyen
2023-05-05 3:58 ` [PATCH V3 2/5] RedfishPkg: Fix condition checking of error status Minh Nguyen
2023-05-05 3:58 ` [PATCH V3 3/5] RedfishPkg: Create RestEx child on selected interface Minh Nguyen
2023-05-05 3:58 ` [PATCH V3 4/5] RedfishPkg: Add missing newline character Minh Nguyen
2023-05-05 3:58 ` [PATCH V3 5/5] RedfishPkg: Fix compile issue on Linux Minh Nguyen
2023-05-05 22:57 ` [edk2-devel] " Pedro Falcato
2023-05-05 23:32 ` Michael D Kinney
2023-05-07 5:39 ` Minh Nguyen [this message]
2023-05-07 6:22 ` Minh Nguyen
2023-05-05 5:03 ` [PATCH V3 0/5] Adding necessary changes for RedfishPkg Chang, Abner
2023-05-05 5:35 ` Minh Nguyen
2023-05-05 5:45 ` Chang, Abner
2023-05-05 6:01 ` Minh Nguyen
2023-05-05 6:50 ` Minh Nguyen
2023-05-08 13:45 ` Chang, Abner
2023-05-09 0:46 ` Minh Nguyen
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=d6a6e209-7a5a-30cc-3202-ea4643ade21f@amperemail.onmicrosoft.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