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 E3CCD22590E2F for ; Tue, 17 Apr 2018 06:20:34 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2018 06:20:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,463,1517904000"; d="scan'208";a="38063927" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga002.fm.intel.com with ESMTP; 17 Apr 2018 06:20:34 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 17 Apr 2018 06:20:34 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.79]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.6]) with mapi id 14.03.0319.002; Tue, 17 Apr 2018 21:20:32 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v1 1/2] BaseTools: fix None comparisons Thread-Index: AQHT0rrI2zEIbUdBK0GElirFwT1SgKQE+CIQ Date: Tue, 17 Apr 2018 13:20: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/2] BaseTools: fix None comparisons 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, 17 Apr 2018 13:20:35 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 Sent: Friday, April 13, 2018 8:02 AM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Zhu, Yonghong Subject: [PATCH v1 1/2] BaseTools: fix None comparisons when comparing a list/string against None and empty, just compare the objec= t. when comparing against None, dont use !=3D, =3D=3D, <> Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/AutoGen.py | 2= +- BaseTools/Source/Python/AutoGen/GenC.py | 2= +- BaseTools/Source/Python/GenFds/Fv.py | 5= ++--- BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py | 6= +++--- BaseTools/Source/Python/Workspace/DscBuildData.py | 4= ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index dbc9f893c2f1..2613c77a7a10 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1675,7 +1675,7 @@ class PlatformAutoGen(AutoGen): DscPcdEntry.TokenValue =3D Dec= PcdEntry.TokenValue DscPcdEntry.TokenSpaceGuidValu= e =3D eachDec.Guids[DecPcdEntry.TokenSpaceGuidCName] # Only fix the value while no = value provided in DSC file. - if (Sku.DefaultValue =3D=3D ""= or Sku.DefaultValue=3D=3DNone): + if not Sku.DefaultValue: DscPcdEntry.SkuInfoList[Ds= cPcdEntry.SkuInfoList.keys()[0]].DefaultValue =3D DecPcdEntry.DefaultValue = =20 if DscPcdEntry not in self._DynamicPcdList= : diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/AutoGen/GenC.py index 58da9e6b1784..a15eb707421e 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1534,7 +1534,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGe= nH): } =20 if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE', 'MM_CORE_ST= ANDALONE']: - if Info.SourceFileList <> None and Info.SourceFileList <> []: + if Info.SourceFileList: if NumEntryPoints !=3D 1: EdkLogger.error( "build", diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python= /GenFds/Fv.py index 345ad3bdcc90..aae644bef905 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -337,11 +337,10 @@ class FV (FvClassObject): # # Generate FV extension header file # - if self.FvNameGuid is None or self.FvNameGuid =3D=3D '': + if not self.FvNameGuid: if len(self.FvExtEntryType) > 0 or self.UsedSizeEnable: GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entr= ies declared for %s with no FvNameGuid declaration." % (self.UiFvName)) - =20 - if self.FvNameGuid <> None and self.FvNameGuid <> '': + else: TotalSize =3D 16 + 4 Buffer =3D '' if self.UsedSizeEnable: diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Generat= eKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateK= eys.py index 95a636966c59..9711de8f5c2e 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.p= y +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKey +++ s.py @@ -9,7 +9,7 @@ # on STDOUT. # This tool has been tested with OpenSSL 1.0.1e 11 Feb 2013 # -# Copyrigh= t (c) 2013 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2013 - 2018, Intel Corporation. All rights=20 +reserved.
# This program and the accompanying materials # are licensed and made ava= ilable under the terms and conditions of the BSD License # which accompani= es this distribution. The full text of the license may be found at @@ -89,= 7 +89,7 @@ if __name__ =3D=3D '__main__': # # Check for output file argument # - if args.OutputFile <> None: + if args.OutputFile is not None: for Item in args.OutputFile: # # Save PEM filename and close output file @@ -109,7 +109,7 @@ if __n= ame__ =3D=3D '__main__': # # Check for input file argument # - if args.InputFile <> None: + if args.InputFile is not None: for Item in args.InputFile: # # Save PEM filename and close input file diff --git a/BaseTools/Sour= ce/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/Dsc= BuildData.py index 6766f059b0f7..9c77d6c50c27 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -2292,7 +2292,7 @@ class DscBuildData(PlatformBuildClassObject): pcdDecObject =3D self._DecPcds[pcd.TokenCName, pcd.TokenSpaceG= uidCName] # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): - if (sku.DefaultValue =3D=3D "" or sku.DefaultValue=3D=3DNo= ne): + if not sku.DefaultValue: sku.DefaultValue =3D pcdDecObject.DefaultValue if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in= pcd.SkuInfoList.keys(): valuefromDec =3D pcdDecObject.DefaultValue @@ -2624,7 +262= 4,7 @@ class DscBuildData(PlatformBuildClassObject): pcd.DatumType =3D pcdDecObject.DatumType # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): - if (sku.DefaultValue =3D=3D "" or sku.DefaultValue=3D=3DNo= ne): + if not sku.DefaultValue: sku.DefaultValue =3D pcdDecObject.DefaultValue if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in= pcd.SkuInfoList.keys(): valuefromDec =3D pcdDecObject.DefaultValue -- 2.16.2.windows.1