diff options
author | Carsey, Jaben <jaben.carsey@intel.com> | 2018-04-20 23:51:42 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-05-02 15:02:20 +0800 |
commit | c93356ada99e6f8083a64f99d162b44a2765ce63 (patch) | |
tree | 1bb64928b259fc66d7e8512a116a758b33a465a1 /BaseTools/Source/Python/GenFds | |
parent | 1beb268a686344d92f42ced656edf46c626e9413 (diff) | |
download | edk2-c93356ada99e6f8083a64f99d162b44a2765ce63.tar.gz edk2-c93356ada99e6f8083a64f99d162b44a2765ce63.tar.bz2 edk2-c93356ada99e6f8083a64f99d162b44a2765ce63.zip |
BaseTools: remove redundant if comparison
inherently python will check string and list for None and having data
if <x> in [None, ''] and similar are superflous.
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>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/GenFds')
-rw-r--r-- | BaseTools/Source/Python/GenFds/FfsInfStatement.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 32 |
2 files changed, 18 insertions, 18 deletions
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 728997f17d..c332eee607 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -297,7 +297,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # Check value, if value are equal, no need to patch
if Pcd.DatumType == TAB_VOID:
- if Pcd.InfDefaultValue == DefaultValue or DefaultValue in [None, '']:
+ if Pcd.InfDefaultValue == DefaultValue or not DefaultValue:
continue
# Get the string size from FDF or DSC
if DefaultValue[0] == 'L':
@@ -310,7 +310,7 @@ class FfsInfStatement(FfsInfStatementClassObject): if DscOverride:
Pcd.MaxDatumSize = PatchPcd.MaxDatumSize
# If no defined the maximum size in DSC, try to get current size from INF
- if Pcd.MaxDatumSize in ['', None]:
+ if not Pcd.MaxDatumSize:
Pcd.MaxDatumSize = str(len(Pcd.InfDefaultValue.split(',')))
else:
Base1 = Base2 = 10
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 2fb98007ab..6cf82526ef 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -102,7 +102,7 @@ class GenFdsGlobalVariable: TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)
if DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF in TargetTxt.TargetTxtDictionary:
BuildRuleFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF]
- if BuildRuleFile in [None, '']:
+ if not BuildRuleFile:
BuildRuleFile = 'Conf/build_rule.txt'
GenFdsGlobalVariable.__BuildRuleDatabase = BuildRule(BuildRuleFile)
ToolDefinitionFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]
@@ -441,15 +441,15 @@ class GenFdsGlobalVariable: def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,
GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None, DummyFile=None, IsMakefile=False):
Cmd = ["GenSec"]
- if Type not in [None, '']:
+ if Type:
Cmd += ["-s", Type]
- if CompressionType not in [None, '']:
+ if CompressionType:
Cmd += ["-c", CompressionType]
if Guid is not None:
Cmd += ["-g", Guid]
if DummyFile is not None:
Cmd += ["--dummy", DummyFile]
- if GuidHdrLen not in [None, '']:
+ if GuidHdrLen:
Cmd += ["-l", GuidHdrLen]
if len(GuidAttr) != 0:
#Add each guided attribute
@@ -461,7 +461,7 @@ class GenFdsGlobalVariable: Cmd += ["--sectionalign", SecAlign]
CommandFile = Output + '.txt'
- if Ui not in [None, '']:
+ if Ui:
#Cmd += ["-n", '"' + Ui + '"']
if IsMakefile:
if Ui == "$(MODULE_NAME)":
@@ -480,7 +480,7 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)
SaveFileOnChange(Output, SectionData.tostring())
- elif Ver not in [None, '']:
+ elif Ver:
Cmd += ["-n", Ver]
if BuildNumber:
Cmd += ["-j", BuildNumber]
@@ -529,7 +529,7 @@ class GenFdsGlobalVariable: Cmd += ["-x"]
if CheckSum:
Cmd += ["-s"]
- if Align not in [None, '']:
+ if Align:
if Align not in mFfsValidAlign:
Align = GenFdsGlobalVariable.GetAlignment (Align)
for index in range(0, len(mFfsValidAlign) - 1):
@@ -541,7 +541,7 @@ class GenFdsGlobalVariable: Cmd += ["-o", Output]
for I in range(0, len(Input)):
Cmd += ("-i", Input[I])
- if SectionAlign not in [None, '', []] and SectionAlign[I] not in [None, '']:
+ if SectionAlign and SectionAlign[I]:
Cmd += ("-n", SectionAlign[I])
CommandFile = Output + '.txt'
@@ -566,7 +566,7 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
Cmd = ["GenFv"]
- if BaseAddress not in [None, '']:
+ if BaseAddress:
Cmd += ["-r", BaseAddress]
if ForceRebase == False:
@@ -578,9 +578,9 @@ class GenFdsGlobalVariable: Cmd += ["-c"]
if Dump:
Cmd += ["-p"]
- if AddressFile not in [None, '']:
+ if AddressFile:
Cmd += ["-a", AddressFile]
- if MapFile not in [None, '']:
+ if MapFile:
Cmd += ["-m", MapFile]
if FileSystemGuid:
Cmd += ["-g", FileSystemGuid]
@@ -597,7 +597,7 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
Cmd = ["GenVtf"]
- if BaseAddress not in [None, ''] and FvSize not in [None, ''] \
+ if BaseAddress and FvSize \
and len(BaseAddress) == len(FvSize):
for I in range(0, len(BaseAddress)):
Cmd += ["-r", BaseAddress[I], "-s", FvSize[I]]
@@ -618,13 +618,13 @@ class GenFdsGlobalVariable: Cmd = ["GenFw"]
if Type.lower() == "te":
Cmd += ["-t"]
- if SubType not in [None, '']:
+ if SubType:
Cmd += ["-e", SubType]
- if TimeStamp not in [None, '']:
+ if TimeStamp:
Cmd += ["-s", TimeStamp]
- if Align not in [None, '']:
+ if Align:
Cmd += ["-a", Align]
- if Padding not in [None, '']:
+ if Padding:
Cmd += ["-p", Padding]
if Zero:
Cmd += ["-z"]
|