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=yonghong.zhu@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 45DB020957445 for ; Tue, 27 Mar 2018 19:15:40 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2018 19:17:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,369,1517904000"; d="scan'208";a="215313012" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga006.fm.intel.com with ESMTP; 27 Mar 2018 19:17:34 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 27 Mar 2018 19:17:34 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.235]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.226]) with mapi id 14.03.0319.002; Wed, 28 Mar 2018 10:17:33 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v1 1/4] BaseTools: remove irrelevant code Thread-Index: AQHTxiVWsJa/C1/ndEaoS4enH4OWnqPk5jMQ Date: Wed, 28 Mar 2018 02:17:31 +0000 Message-ID: References: In-Reply-To: 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 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 02:15:40 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Jaben, 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 be rem= oved since it maybe a list after SplitPcdValueString function. https://bugzilla.tianocore.org/show_bug.cgi?id=3D541 is the feature request= for flexible Pcd value format. Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 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 Since PcdValue is a string, no need to test it's type() for string Also rem= ove the block used if it's a list (which is never is) 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(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/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', 'BO= OLEAN']: PcdValue =3D PcdValue.strip() - if type(PcdValue) =3D=3D type('') and PcdValue.startswith(= '{') 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 numbe= r %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 ItemValue.= startswith('0x') else int(ItemValue) - - TmpValue =3D (ItemValue << (Size * 8)) | TmpValue - Size =3D Size + ItemSize - else: - try: - TmpValue, Size =3D ParseFieldValue(PcdValue) - except BadExpression, Value: - raise BadExpression("Type: %s, Value: %s, %s" % (s= elf.PcdType, PcdValue, Value)) + try: + TmpValue, Size =3D ParseFieldValue(PcdValue) + except BadExpression, Value: + raise BadExpression("Type: %s, Value: %s, %s" %=20 + (self.PcdType, PcdValue, Value)) if type(TmpValue) =3D=3D type(''): try: TmpValue =3D int(TmpValue) -- 2.16.2.windows.1