From: Jaben <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [PATCH v1 1/2] BaseTools: fix None comparisons
Date: Thu, 12 Apr 2018 17:02:10 -0700 [thread overview]
Message-ID: <c6baf546e1759fa0b394adebccc86dc863d1d77f.1523577634.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1523577634.git.jaben.carsey@intel.com>
In-Reply-To: <cover.1523577634.git.jaben.carsey@intel.com>
when comparing a list/string against None and empty, just compare the object.
when comparing against None, dont use !=, ==, <>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
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 = DecPcdEntry.TokenValue
DscPcdEntry.TokenSpaceGuidValue = eachDec.Guids[DecPcdEntry.TokenSpaceGuidCName]
# Only fix the value while no value provided in DSC file.
- if (Sku.DefaultValue == "" or Sku.DefaultValue==None):
+ if not Sku.DefaultValue:
DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue
if DscPcdEntry not in self._DynamicPcdList:
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/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, AutoGenH):
}
if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE', 'MM_CORE_STANDALONE']:
- if Info.SourceFileList <> None and Info.SourceFileList <> []:
+ if Info.SourceFileList:
if NumEntryPoints != 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 == '':
+ if not self.FvNameGuid:
if len(self.FvExtEntryType) > 0 or self.UsedSizeEnable:
GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entries declared for %s with no FvNameGuid declaration." % (self.UiFvName))
-
- if self.FvNameGuid <> None and self.FvNameGuid <> '':
+ else:
TotalSize = 16 + 4
Buffer = ''
if self.UsedSizeEnable:
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
index 95a636966c59..9711de8f5c2e 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
@@ -9,7 +9,7 @@
# on STDOUT.
# This tool has been tested with OpenSSL 1.0.1e 11 Feb 2013
#
-# Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -89,7 +89,7 @@ if __name__ == '__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 __name__ == '__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/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.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 = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName]
# Only fix the value while no value provided in DSC file.
for sku in pcd.SkuInfoList.values():
- if (sku.DefaultValue == "" or sku.DefaultValue==None):
+ if not sku.DefaultValue:
sku.DefaultValue = pcdDecObject.DefaultValue
if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
valuefromDec = pcdDecObject.DefaultValue
@@ -2624,7 +2624,7 @@ class DscBuildData(PlatformBuildClassObject):
pcd.DatumType = pcdDecObject.DatumType
# Only fix the value while no value provided in DSC file.
for sku in pcd.SkuInfoList.values():
- if (sku.DefaultValue == "" or sku.DefaultValue==None):
+ if not sku.DefaultValue:
sku.DefaultValue = pcdDecObject.DefaultValue
if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
valuefromDec = pcdDecObject.DefaultValue
--
2.16.2.windows.1
next prev parent reply other threads:[~2018-04-13 0:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-13 0:02 [PATCH v1 0/2] BaseTools: refactor for code simplification Jaben
2018-04-13 0:02 ` Jaben [this message]
2018-04-17 13:20 ` [PATCH v1 1/2] BaseTools: fix None comparisons Zhu, Yonghong
2018-04-13 0:02 ` [PATCH v1 2/2] BaseTools: refactor and remove un-needed use of .keys() on dictionaries Jaben
2018-04-17 13:25 ` Zhu, Yonghong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c6baf546e1759fa0b394adebccc86dc863d1d77f.1523577634.git.jaben.carsey@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox