From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 79AEE201B0423 for ; Tue, 19 Feb 2019 01:21:40 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2019 01:21:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,387,1544515200"; d="scan'208";a="123530839" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga007.fm.intel.com with ESMTP; 19 Feb 2019 01:21:39 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 19 Feb 2019 01:21:39 -0800 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 19 Feb 2019 01:21:38 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.102]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.174]) with mapi id 14.03.0415.000; Tue, 19 Feb 2019 17:21:34 +0800 From: "Gao, Liming" To: "Feng, Bob C" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] BaseTools: Fixed a code bug for Pcd Array. Thread-Index: AQHUxbwYJDuUI1NbgkePIppcv14qNKXm3YhA Date: Tue, 19 Feb 2019 09:21:35 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3E171C@SHSMSX104.ccr.corp.intel.com> References: <20190216055413.21412-1-bob.c.feng@intel.com> In-Reply-To: <20190216055413.21412-1-bob.c.feng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Fixed a code bug for Pcd Array. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Feb 2019 09:21:41 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----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 >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 >Cc: Liming Gao >--- > 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 =3D self.GetIndicator(index, FieldName,Pcd) > if IsArray: > # > # Use memcpy() to copy value into field > # >- CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s)= ;\n' % >(Pcd.DatumType, FieldName) >+ CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s)= ;\n' % >(Pcd.BaseDatumType, FieldName) > CApp =3D CApp + ' Value =3D %s; // From %s Line = %d Value %s\n' % >(DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1], >FieldList[FieldName][2], FieldList[FieldName][0]) >- CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, = %s) >=3D %d) >|| (__FIELD_SIZE(%s, %s) =3D=3D 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 =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSiz= e > 0 && >FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize) >+ CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, = %s) >=3D %d) >|| (__FIELD_SIZE(%s, %s) =3D=3D 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 =3D CApp + ' memcpy (&%s, Value, (FieldSize > 0= && FieldSize >< %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize) > elif isinstance(Value, str): > CApp =3D CApp + ' %s =3D %s; // From %s Line %d Valu= e %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 =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s,= %s);\n' % >(Pcd.BaseDatumType, FieldName) > CApp =3D CApp + ' Value =3D %s; // From %s L= ine %d Value %s\n' % >(DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1], >FieldList[FieldName][2], FieldList[FieldName][0]) >- CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(= %s, %s) >=3D %d) >|| (__FIELD_SIZE(%s, %s) =3D=3D 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 =3D CApp + ' memcpy (&Pcd->%s, Value, (Fiel= dSize > 0 && >FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize) >+ CApp =3D CApp + ' >__STATIC_ASSERT((__FIELD_SIZE(%s, %s) >=3D %d) || (__FIELD_SIZE(%s, %s) >=3D=3D 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 =3D CApp + ' memcpy (&%s, Value, (FieldSize= > 0 && FieldSize >< %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize) > else: > if '[' in FieldName and ']' in FieldName: > Index =3D int(FieldName.split('[')[1].split('= ]')[0]) > CApp =3D CApp + ' __STATIC_ASSERT((%d < __AR= RAY_SIZE(Pcd- >>%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 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 =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s)= ;\n' % >(Pcd.BaseDatumType, FieldName) > CApp =3D CApp + ' Value =3D %s; // From %s Line = %d Value %s\n' % >(DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1], >FieldList[FieldName][2], FieldList[FieldName][0]) >- CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, = %s) >=3D %d) >|| (__FIELD_SIZE(%s, %s) =3D=3D 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 =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, = %s) >=3D %d) >|| (__FIELD_SIZE(%s, %s) =3D=3D 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 =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSiz= e > 0 && >FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize) > else: > if '[' in FieldName and ']' in FieldName: > Index =3D int(FieldName.split('[')[1].split(']')[= 0]) > CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARRAY_= SIZE(Pcd- >>%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 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 =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s)= ;\n' % >(Pcd.BaseDatumType, FieldName) > CApp =3D CApp + ' Value =3D %s; // From %s Line = %d Value %s\n' % >(DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1], >FieldList[FieldName][2], FieldList[FieldName][0]) >- CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, = %s) >=3D %d) >|| (__FIELD_SIZE(%s, %s) =3D=3D 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 =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, = %s) >=3D %d) >|| (__FIELD_SIZE(%s, %s) =3D=3D 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 =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSiz= e > 0 && >FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize) > else: > if '[' in FieldName and ']' in FieldName: > Index =3D int(FieldName.split('[')[1].split(']')[= 0]) > CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARRAY_= SIZE(Pcd- >>%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 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