From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 CAF6521167455 for ; Thu, 18 Oct 2018 07:36:18 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Oct 2018 07:36:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,396,1534834800"; d="scan'208";a="82492230" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga008.jf.intel.com with ESMTP; 18 Oct 2018 07:36:17 -0700 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 18 Oct 2018 07:36:17 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.16]) by fmsmsx121.amr.corp.intel.com ([169.254.6.136]) with mapi id 14.03.0319.002; Thu, 18 Oct 2018 07:36:17 -0700 From: "Carsey, Jaben" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] BaseTools: Fix one crash bug in the report for Fixed structure Pcd Thread-Index: AQHUZu5wlsozTx+Y002ubduPi0ivQqUlEcTA Date: Thu, 18 Oct 2018 14:36:16 +0000 Message-ID: References: <1539872727-8316-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1539872727-8316-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODRhMjhkZmMtZmRlYS00ZTdmLThiOTEtNTgzYjU4NDFmOTI4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibTNxbkxONUVkTHNWblJLc0I1MzhFN1U2NDdMVEErUVZPSnRJdmp4dmxEdGpiMlNyNVVHSDMxaWxVRUU4VmdTciJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.1.200.106] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Fix one crash bug in the report for Fixed structure Pcd 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: Thu, 18 Oct 2018 14:36:19 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey Note that you could change your first 2 lines (of the new content in both p= laces) to: for Data in OverrideValues.values(): since you don't ever use the key later on... -Jaben > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Yonghong Zhu > Sent: Thursday, October 18, 2018 7:25 AM > To: edk2-devel@lists.01.org > Subject: [edk2] [Patch] BaseTools: Fix one crash bug in the report for Fi= xed > structure Pcd >=20 > The case is: > in the DSC file: > SKUID_IDENTIFIER =3D ALL >=20 > [SkuIds] > 0|DEFAULT > 1|A >=20 > [PcdsFixedAtBuild.common.A] > TokenSpaceGuid.Test401|{0x0F, 0x12} > TokenSpaceGuid.Test401.TEST401INT8ARRAY[0]|'B' >=20 > in the build report, Data =3D OverrideValues[Keys[0]], but the Keys[0] > is the keyword "DEFAULT", and in this case the "DEFAULT" SKU doesn't > save any value, then it cause the Data is empty, in the next code > when we use the code it cause crash. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Yonghong Zhu > --- > BaseTools/Source/Python/build/BuildReport.py | 23 +++++++++++++-------- > -- > 1 file changed, 13 insertions(+), 10 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/build/BuildReport.py > b/BaseTools/Source/Python/build/BuildReport.py > index 14143b3..5e2a664 100644 > --- a/BaseTools/Source/Python/build/BuildReport.py > +++ b/BaseTools/Source/Python/build/BuildReport.py > @@ -1089,14 +1089,16 @@ class PcdReport(object): > DscOverride =3D False > else: > if not Pcd.SkuInfoList: > OverrideValues =3D Pcd.SkuOverrideVa= lues > if OverrideValues: > - Keys =3D list(OverrideValues.key= s()) > - Data =3D OverrideValues[Keys[0]] > - Struct =3D list(Data.values()) > - DscOverride =3D self.ParseStruct= (Struct[0]) > + for key in OverrideValues.keys()= : > + Data =3D OverrideValues[key] > + Struct =3D list(Data.values(= )) > + if Struct: > + DscOverride =3D self.Par= seStruct(Struct[0]) > + break > else: > SkuList =3D sorted(Pcd.SkuInfoList.k= eys()) > for Sku in SkuList: > SkuInfo =3D Pcd.SkuInfoList[Sku] > if TypeName in ('DYNHII', 'DEXHI= I'): > @@ -1265,16 +1267,17 @@ class PcdReport(object): > Value =3D "0x{:X} ({})".format(int(Value, 0), Va= lue) > FileWrite(File, ' %-*s : %6s %10s =3D %s' % (self.MaxL= en, Flag + ' ' + > PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value)) > if IsStructure: > OverrideValues =3D Pcd.SkuOverrideValues > if OverrideValues: > - Keys =3D list(OverrideValues.keys()) > - Data =3D OverrideValues[Keys[0]] > - Struct =3D list(Data.values()) > - if Struct: > - OverrideFieldStruct =3D self.OverrideFieldValue(= Pcd, Struct[0]) > - self.PrintStructureInfo(File, OverrideFieldStruc= t) > + for key in OverrideValues.keys(): > + Data =3D OverrideValues[key] > + Struct =3D list(Data.values()) > + if Struct: > + OverrideFieldStruct =3D self.OverrideFieldVa= lue(Pcd, Struct[0]) > + self.PrintStructureInfo(File, OverrideFieldS= truct) > + break > self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDe= faultValue, > InfMatch, InfDefaultValue, DecMatch, DecDefaultValue) > else: > FirstPrint =3D True > SkuList =3D sorted(Pcd.SkuInfoList.keys()) > for Sku in SkuList: > -- > 2.6.1.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel