From: "Gao, Liming" <liming.gao@intel.com>
To: "Feng, Bob C" <bob.c.feng@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [Patch] BaseTools: Fixed a code bug for Pcd Array.
Date: Tue, 19 Feb 2019 09:21:35 +0000 [thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3E171C@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20190216055413.21412-1-bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>Feng, Bob C
>Sent: Saturday, February 16, 2019 1:54 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [edk2] [Patch] BaseTools: Fixed a code bug for Pcd Array.
>
>For example, PCD gUefiOvmfPkgTokenSpaceGuid.Test001 datatype is Array:
>TEST1[2]
>and the filed TEST1UINT64ARRAY in TEST1 is also an array:
>UINT64 TEST1UINT64ARRAY[2];
>
>Then the following filed assignment in DSC will cause build failure.
>gUefiOvmfPkgTokenSpaceGuid.Test001[0].TEST1UINT64ARRAY|{'A','B'}
>
>The root cause is build tool generate incorrect PcdValueInit.c File.
>
>This patch is going to fix this issue.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng <bob.c.feng@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>---
> BaseTools/Source/Python/Workspace/DscBuildData.py | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
>diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
>b/BaseTools/Source/Python/Workspace/DscBuildData.py
>index 1fd1639ab6..e45beb3924 100644
>--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
>@@ -2015,14 +2015,13 @@ class DscBuildData(PlatformBuildClassObject):
> indicator = self.GetIndicator(index, FieldName,Pcd)
> if IsArray:
> #
> # Use memcpy() to copy value into field
> #
>- CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' %
>(Pcd.DatumType, FieldName)
>+ CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' %
>(Pcd.BaseDatumType, FieldName)
> CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' %
>(DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
>- CApp = CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d)
>|| (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); //
>From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize,
>Pcd.DatumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2],
>FieldList[FieldName][0])
>- CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 &&
>FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
>+ CApp = CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d)
>|| (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); //
>From %s Line %d Value %s\n' % (Pcd.BaseDatumType, FieldName, ValueSize,
>Pcd.BaseDatumType, FieldName, FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
> CApp = CApp + ' memcpy (&%s, Value, (FieldSize > 0 && FieldSize
>< %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize)
> elif isinstance(Value, str):
> CApp = CApp + ' %s = %s; // From %s Line %d Value %s\n' %
>(indicator, Value, FieldList[FieldName][1], FieldList[FieldName][2],
>FieldList[FieldName][0])
> else:
> if '[' in FieldName and ']' in FieldName:
>@@ -2130,12 +2129,11 @@ class DscBuildData(PlatformBuildClassObject):
> #
> # Use memcpy() to copy value into field
> #
> CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' %
>(Pcd.BaseDatumType, FieldName)
> CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' %
>(DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
>- CApp = CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d)
>|| (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); //
>From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize,
>Pcd.DatumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2],
>FieldList[FieldName][0])
>- CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 &&
>FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
>+ CApp = CApp + '
>__STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d) || (__FIELD_SIZE(%s, %s)
>== 0), "Input buffer exceeds the buffer array"); // From %s Line %d
>Value %s\n' % (Pcd.BaseDatumType, FieldName, ValueSize,
>Pcd.BaseDatumType, FieldName, FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
> CApp = CApp + ' memcpy (&%s, Value, (FieldSize > 0 && FieldSize
>< %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize)
> else:
> if '[' in FieldName and ']' in FieldName:
> Index = int(FieldName.split('[')[1].split(']')[0])
> CApp = CApp + ' __STATIC_ASSERT((%d < __ARRAY_SIZE(Pcd-
>>%s)) || (__ARRAY_SIZE(Pcd->%s) == 0), "array index exceeds the array
>number"); // From %s Line %d Index of %s\n' % (Index, FieldName.split('[')[0],
>FieldName.split('[')[0], FieldList[FieldName][1], FieldList[FieldName][2],
>FieldName)
>@@ -2200,11 +2198,11 @@ class DscBuildData(PlatformBuildClassObject):
> #
> # Use memcpy() to copy value into field
> #
> CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' %
>(Pcd.BaseDatumType, FieldName)
> CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' %
>(DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
>- CApp = CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d)
>|| (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); //
>From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize,
>Pcd.DatumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2],
>FieldList[FieldName][0])
>+ CApp = CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d)
>|| (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); //
>From %s Line %d Value %s\n' % (Pcd.BaseDatumType, FieldName, ValueSize,
>Pcd.BaseDatumType, FieldName, FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
> CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 &&
>FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
> else:
> if '[' in FieldName and ']' in FieldName:
> Index = int(FieldName.split('[')[1].split(']')[0])
> CApp = CApp + ' __STATIC_ASSERT((%d < __ARRAY_SIZE(Pcd-
>>%s)) || (__ARRAY_SIZE(Pcd->%s) == 0), "array index exceeds the array
>number"); // From %s Line %d Index of %s\n' % (Index, FieldName.split('[')[0],
>FieldName.split('[')[0], FieldList[FieldName][1], FieldList[FieldName][2],
>FieldName)
>@@ -2268,11 +2266,11 @@ class DscBuildData(PlatformBuildClassObject):
> #
> # Use memcpy() to copy value into field
> #
> CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' %
>(Pcd.BaseDatumType, FieldName)
> CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' %
>(DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
>- CApp = CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d)
>|| (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); //
>From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize,
>Pcd.DatumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2],
>FieldList[FieldName][0])
>+ CApp = CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d)
>|| (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); //
>From %s Line %d Value %s\n' % (Pcd.BaseDatumType, FieldName, ValueSize,
>Pcd.BaseDatumType, FieldName, FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
> CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 &&
>FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
> else:
> if '[' in FieldName and ']' in FieldName:
> Index = int(FieldName.split('[')[1].split(']')[0])
> CApp = CApp + ' __STATIC_ASSERT((%d < __ARRAY_SIZE(Pcd-
>>%s)) || (__ARRAY_SIZE(Pcd->%s) == 0), "array index exceeds the array
>number"); // From %s Line %d Index of %s\n' % (Index, FieldName.split('[')[0],
>FieldName.split('[')[0], FieldList[FieldName][1], FieldList[FieldName][2],
>FieldName)
>--
>2.18.0.windows.1
>
>_______________________________________________
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel
prev parent reply other threads:[~2019-02-19 9:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-16 5:54 [Patch] BaseTools: Fixed a code bug for Pcd Array Feng, Bob C
2019-02-19 9:21 ` Gao, Liming [this message]
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=4A89E2EF3DFEDB4C8BFDE51014F606A14E3E171C@SHSMSX104.ccr.corp.intel.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