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.100; helo=mga07.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 97CC121E256AC for ; Tue, 27 Mar 2018 16:36:16 -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 orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2018 16:42:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,368,1517904000"; d="scan'208";a="28995252" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga008.jf.intel.com with ESMTP; 27 Mar 2018 16:42:52 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu Date: Tue, 27 Mar 2018 16:42:44 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [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: Tue, 27 Mar 2018 23:36:17 -0000 Since PcdValue is a string, no need to test it's type() for string Also remove 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/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 = PcdValue.strip() - if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'): + if PcdValue.startswith('{') and PcdValue.endswith('}'): PcdValue = SplitPcdValueString(PcdValue[1:-1]) - if type(PcdValue) == type([]): - TmpValue = 0 - Size = 0 - ValueType = '' - for Item in PcdValue: - Item = Item.strip() - if Item.startswith('UINT8'): - ItemSize = 1 - ValueType = 'UINT8' - elif Item.startswith('UINT16'): - ItemSize = 2 - ValueType = 'UINT16' - elif Item.startswith('UINT32'): - ItemSize = 4 - ValueType = 'UINT32' - elif Item.startswith('UINT64'): - ItemSize = 8 - ValueType = 'UINT64' - elif Item.startswith('"') or Item.startswith("'") or Item.startswith('L'): - ItemSize = 0 - ValueType = 'VOID*' - else: - ItemSize = 0 - ValueType = 'UINT8' - Item = ValueExpressionEx(Item, ValueType, self._Symb)(True) - - if ItemSize == 0: - try: - tmpValue = int(Item, 16) if Item.upper().startswith('0X') else int(Item, 0) - if tmpValue > 255: - raise BadExpression("Byte array number %s should less than 0xFF." % Item) - except BadExpression, Value: - raise BadExpression(Value) - except ValueError: - pass - ItemValue, ItemSize = ParseFieldValue(Item) - else: - ItemValue = ParseFieldValue(Item)[0] - - if type(ItemValue) == type(''): - ItemValue = int(ItemValue, 16) if ItemValue.startswith('0x') else int(ItemValue) - - TmpValue = (ItemValue << (Size * 8)) | TmpValue - Size = Size + ItemSize - else: - try: - TmpValue, Size = ParseFieldValue(PcdValue) - except BadExpression, Value: - raise BadExpression("Type: %s, Value: %s, %s" % (self.PcdType, PcdValue, Value)) + try: + TmpValue, Size = ParseFieldValue(PcdValue) + except BadExpression, Value: + raise BadExpression("Type: %s, Value: %s, %s" % (self.PcdType, PcdValue, Value)) if type(TmpValue) == type(''): try: TmpValue = int(TmpValue) -- 2.16.2.windows.1