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.88; helo=mga01.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 C0D2D22106DDE for ; Wed, 28 Mar 2018 07:51:01 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2018 07:57:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,372,1517904000"; d="scan'208";a="46021476" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga002.jf.intel.com with ESMTP; 28 Mar 2018 07:57:39 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.89]) by fmsmsx104.amr.corp.intel.com ([169.254.3.60]) with mapi id 14.03.0319.002; Wed, 28 Mar 2018 07:57:38 -0700 From: "Carsey, Jaben" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [PATCH v1 1/4] BaseTools: remove irrelevant code Thread-Index: AQHTxjrvbrKuO0k7tk+fePP2RpOKfqPlvTiQ Date: Wed, 28 Mar 2018 14:57:37 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTdhNTZhMTctZDJmZS00YmFkLTk5NGEtNTVlNWQ5ZjlkYWYzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IjdBSVdGT0dEdzNzaDVVbWh4cSs2bUwzWXNPMVNcL2pQYmNIeFNhb2EwRUNNPSJ9 x-ctpclassification: CTP_NT x-originating-ip: [10.1.200.106] MIME-Version: 1.0 Subject: Re: [PATCH v1 1/4] BaseTools: remove irrelevant code X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Mar 2018 14:51:02 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Zhu, Given that the statement ~1 line above "PcdValue =3D PcdValue.strip()" will= raise exception with a PcdValue that is a list, I don't see how this code = could execute. I agree that it is likely that we think we want this, but something is wron= g with it and I assumed that the current behavior was the desired behavior.= If I am incorrect, please feel free to disregard this patch. -Jaben > -----Original Message----- > From: Zhu, Yonghong > Sent: Tuesday, March 27, 2018 7:18 PM > To: Carsey, Jaben ; edk2-devel@lists.01.org > Cc: Gao, Liming ; Zhu, Yonghong > > Subject: RE: [PATCH v1 1/4] BaseTools: remove irrelevant code > Importance: High >=20 > Hi Jaben, >=20 > Current we support flexible PCD value format, example: UINT64 type PCD > can use {0x1, 2, 'A', UINT16(10), "B"} as its value, so the block can't b= e > removed since it maybe a list after SplitPcdValueString function. > https://bugzilla.tianocore.org/show_bug.cgi?id=3D541 is the feature reque= st > for flexible Pcd value format. >=20 > Best Regards, > Zhu Yonghong >=20 >=20 > -----Original Message----- > From: Carsey, Jaben > Sent: Wednesday, March 28, 2018 7:43 AM > To: edk2-devel@lists.01.org > Cc: Gao, Liming ; Zhu, Yonghong > > Subject: [PATCH v1 1/4] BaseTools: remove irrelevant code >=20 > Since PcdValue is a string, no need to test it's type() for string Also r= emove > the block used if it's a list (which is never is) >=20 > Cc: Liming Gao > Cc: Yonghong Zhu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jaben Carsey > --- > BaseTools/Source/Python/Common/Expression.py | 55 ++------------------ > 1 file changed, 5 insertions(+), 50 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/Common/Expression.py > b/BaseTools/Source/Python/Common/Expression.py > index 4f0f377f3788..b70f7da1233e 100644 > --- a/BaseTools/Source/Python/Common/Expression.py > +++ b/BaseTools/Source/Python/Common/Expression.py > @@ -815,57 +815,12 @@ class ValueExpressionEx(ValueExpression): > except BadExpression, Value: > if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', '= BOOLEAN']: > PcdValue =3D PcdValue.strip() > - if type(PcdValue) =3D=3D type('') and PcdValue.startswit= h('{') and > PcdValue.endswith('}'): > + if PcdValue.startswith('{') and PcdValue.endswith('}'): > PcdValue =3D SplitPcdValueString(PcdValue[1:-1]) > - if type(PcdValue) =3D=3D type([]): > - TmpValue =3D 0 > - Size =3D 0 > - ValueType =3D '' > - for Item in PcdValue: > - Item =3D Item.strip() > - if Item.startswith('UINT8'): > - ItemSize =3D 1 > - ValueType =3D 'UINT8' > - elif Item.startswith('UINT16'): > - ItemSize =3D 2 > - ValueType =3D 'UINT16' > - elif Item.startswith('UINT32'): > - ItemSize =3D 4 > - ValueType =3D 'UINT32' > - elif Item.startswith('UINT64'): > - ItemSize =3D 8 > - ValueType =3D 'UINT64' > - elif Item.startswith('"') or Item.startswith("'"= ) or > Item.startswith('L'): > - ItemSize =3D 0 > - ValueType =3D 'VOID*' > - else: > - ItemSize =3D 0 > - ValueType =3D 'UINT8' > - Item =3D ValueExpressionEx(Item, ValueType, self= ._Symb)(True) > - > - if ItemSize =3D=3D 0: > - try: > - tmpValue =3D int(Item, 16) if Item.upper= ().startswith('0X') else > int(Item, 0) > - if tmpValue > 255: > - raise BadExpression("Byte array num= ber %s should less > than 0xFF." % Item) > - except BadExpression, Value: > - raise BadExpression(Value) > - except ValueError: > - pass > - ItemValue, ItemSize =3D ParseFieldValue(Item= ) > - else: > - ItemValue =3D ParseFieldValue(Item)[0] > - > - if type(ItemValue) =3D=3D type(''): > - ItemValue =3D int(ItemValue, 16) if ItemValu= e.startswith('0x') > else int(ItemValue) > - > - TmpValue =3D (ItemValue << (Size * 8)) | TmpValu= e > - Size =3D Size + ItemSize > - else: > - try: > - TmpValue, Size =3D ParseFieldValue(PcdValue) > - except BadExpression, Value: > - raise BadExpression("Type: %s, Value: %s, %s" % = (self.PcdType, > PcdValue, Value)) > + try: > + TmpValue, Size =3D ParseFieldValue(PcdValue) > + except BadExpression, Value: > + raise BadExpression("Type: %s, Value: %s, %s" % > + (self.PcdType, PcdValue, Value)) > if type(TmpValue) =3D=3D type(''): > try: > TmpValue =3D int(TmpValue) > -- > 2.16.2.windows.1