diff options
author | Fan, ZhijuX <zhijux.fan@intel.com> | 2019-09-12 16:18:27 +0800 |
---|---|---|
committer | Feng, Bob C <bob.c.feng@intel.com> | 2019-09-17 10:18:51 +0800 |
commit | e32f7bc96dc8db7af0c1c532e4990c9a36a12354 (patch) | |
tree | 501408aa16702eec58fdebdee5c845317c5f9089 /BaseTools/Source/Python/GenFds | |
parent | b67735a7e8e962b74120bad956d9a0734f784472 (diff) | |
download | edk2-e32f7bc96dc8db7af0c1c532e4990c9a36a12354.tar.gz edk2-e32f7bc96dc8db7af0c1c532e4990c9a36a12354.tar.bz2 edk2-e32f7bc96dc8db7af0c1c532e4990c9a36a12354.zip |
BaseTools:change some incorrect parameter defaults
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1858
for Dict={},There are pitfalls in the way this default parameter is set
and Dict is not used in functions, other functions have these two cases,
I will change some incorrect parameter defaults
This patch is going to fix this issue
Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/GenFds')
-rw-r--r-- | BaseTools/Source/Python/GenFds/AprioriSection.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/CompressSection.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/DataSection.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/EfiSection.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/FfsFileStatement.py | 5 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/FfsInfStatement.py | 5 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/Fv.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/FvImageSection.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 2 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/GuidSection.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/OptRomFileStatement.py | 5 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/Region.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/Section.py | 2 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/UiSection.py | 4 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/VerSection.py | 4 |
15 files changed, 43 insertions, 16 deletions
diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/Source/Python/GenFds/AprioriSection.py index be2d9f6de5..9f64c613eb 100644 --- a/BaseTools/Source/Python/GenFds/AprioriSection.py +++ b/BaseTools/Source/Python/GenFds/AprioriSection.py @@ -46,7 +46,9 @@ class AprioriSection (object): # @param Dict dictionary contains macro and its value
# @retval string Generated file name
#
- def GenFfs (self, FvName, Dict = {}, IsMakefile = False):
+ def GenFfs (self, FvName, Dict = None, IsMakefile = False):
+ if Dict is None:
+ Dict = {}
Buffer = BytesIO()
if self.AprioriType == "PEI":
AprioriFileGuid = PEI_APRIORI_GUID
diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/Source/Python/GenFds/CompressSection.py index 4dae5dba35..e62280fc16 100644 --- a/BaseTools/Source/Python/GenFds/CompressSection.py +++ b/BaseTools/Source/Python/GenFds/CompressSection.py @@ -49,7 +49,7 @@ class CompressSection (CompressSectionClassObject) : # @param Dict dictionary contains macro and its value
# @retval tuple (Generated file name, section alignment)
#
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False):
if FfsInf is not None:
self.CompType = FfsInf.__ExtendMacro__(self.CompType)
@@ -59,6 +59,8 @@ class CompressSection (CompressSectionClassObject) : SectAlign = []
Index = 0
MaxAlign = None
+ if Dict is None:
+ Dict = {}
for Sect in self.SectionList:
Index = Index + 1
SecIndex = '%s.%d' %(SecNum, Index)
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py index 60b94fbe08..f20fd70225 100644 --- a/BaseTools/Source/Python/GenFds/DataSection.py +++ b/BaseTools/Source/Python/GenFds/DataSection.py @@ -44,10 +44,12 @@ class DataSection (DataSectionClassObject): # @param Dict dictionary contains macro and its value
# @retval tuple (Generated file name list, section alignment)
#
- def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}, IsMakefile = False):
+ def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = None, IsMakefile = False):
#
# Prepare the parameter of GenSection
#
+ if Dict is None:
+ Dict = {}
if FfsFile is not None:
self.SectFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.SectFileName)
self.SectFileName = GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict, FfsFile.CurrentArch)
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py index 74f176cfef..db892df345 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -49,7 +49,7 @@ class EfiSection (EfiSectionClassObject): # @param Dict dictionary contains macro and its value
# @retval tuple (Generated file name list, section alignment)
#
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False) :
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False) :
if self.FileName is not None and self.FileName.startswith('PCD('):
self.FileName = GenFdsGlobalVariable.GetPcdValue(self.FileName)
@@ -76,6 +76,8 @@ class EfiSection (EfiSectionClassObject): """If the file name was pointed out, add it in FileList"""
FileList = []
+ if Dict is None:
+ Dict = {}
if Filename is not None:
Filename = GenFdsGlobalVariable.MacroExtend(Filename, Dict)
# check if the path is absolute or relative
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py index 9250361d14..9fb62b0a91 100644 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -48,7 +48,7 @@ class FileStatement (FileStatementClassObject): # @param FvParentAddr Parent Fv base address
# @retval string Generated FFS file name
#
- def GenFfs(self, Dict = {}, FvChildAddr=[], FvParentAddr=None, IsMakefile=False, FvName=None):
+ def GenFfs(self, Dict = None, FvChildAddr=[], FvParentAddr=None, IsMakefile=False, FvName=None):
if self.NameGuid and self.NameGuid.startswith('PCD('):
PcdValue = GenFdsGlobalVariable.GetPcdValue(self.NameGuid)
@@ -70,6 +70,9 @@ class FileStatement (FileStatementClassObject): if not os.path.exists(OutputDir):
os.makedirs(OutputDir)
+ if Dict is None:
+ Dict = {}
+
Dict.update(self.DefineVarDict)
SectionAlignments = None
if self.FvName:
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 43dbd0102f..20573ca28d 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -437,11 +437,12 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param FvParentAddr Parent Fv base address
# @retval string Generated FFS file name
#
- def GenFfs(self, Dict = {}, FvChildAddr = [], FvParentAddr=None, IsMakefile=False, FvName=None):
+ def GenFfs(self, Dict = None, FvChildAddr = [], FvParentAddr=None, IsMakefile=False, FvName=None):
#
# Parse Inf file get Module related information
#
-
+ if Dict is None:
+ Dict = {}
self.__InfParse__(Dict, IsGenFfs=True)
Arch = self.GetCurrentArch()
SrcFile = mws.join( GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName);
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py index 206bd02005..16c944a0bd 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -71,9 +71,11 @@ class FV (object): # @param MacroDict macro value pair
# @retval string Generated FV file path
#
- def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', MacroDict = {}, Flag=False):
+ def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', MacroDict = None, Flag=False):
if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFdsGlobalVariable.ImageBinDict:
return GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv']
+ if MacroDict is None:
+ MacroDict = {}
#
# Check whether FV in Capsule is in FD flash region.
diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py index b2953d822b..ff2d5ca3c0 100644 --- a/BaseTools/Source/Python/GenFds/FvImageSection.py +++ b/BaseTools/Source/Python/GenFds/FvImageSection.py @@ -47,9 +47,11 @@ class FvImageSection(FvImageSectionClassObject): # @param Dict dictionary contains macro and its value
# @retval tuple (Generated file name, section alignment)
#
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False):
OutputFileList = []
+ if Dict is None:
+ Dict = {}
if self.FvFileType is not None:
FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FvFileType, self.FvFileExtension)
if IsSect :
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 3dc73c8f61..4d8b2bdee2 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -742,7 +742,7 @@ class GenFdsGlobalVariable: # @param MacroDict Dictionary that contains macro value pair
#
@staticmethod
- def MacroExtend (Str, MacroDict={}, Arch=DataType.TAB_COMMON):
+ def MacroExtend (Str, MacroDict=None, Arch=DataType.TAB_COMMON):
if Str is None:
return None
diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py index 530e2b3957..8db6e2feb3 100644 --- a/BaseTools/Source/Python/GenFds/GuidSection.py +++ b/BaseTools/Source/Python/GenFds/GuidSection.py @@ -50,7 +50,7 @@ class GuidSection(GuidSectionClassObject) : # @param Dict dictionary contains macro and its value
# @retval tuple (Generated file name, section alignment)
#
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile=False):
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile=False):
#
# Generate all section
#
@@ -66,6 +66,8 @@ class GuidSection(GuidSectionClassObject) : SectAlign = []
Index = 0
MaxAlign = None
+ if Dict is None:
+ Dict = {}
if self.FvAddr != []:
FvAddrIsSet = True
else:
diff --git a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py index 0c54f48da2..1bd4d4572a 100644 --- a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py @@ -34,7 +34,10 @@ class OptRomFileStatement: # @param Dict dictionary contains macro and value pair
# @retval string Generated FFS file name
#
- def GenFfs(self, Dict = {}, IsMakefile=False):
+ def GenFfs(self, Dict = None, IsMakefile=False):
+
+ if Dict is None:
+ Dict = {}
if self.FileName is not None:
self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py index 7d5a3ab173..e95cfcf965 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -73,8 +73,10 @@ class Region(object): # @retval string Generated FV file path
#
- def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, MacroDict={}, Flag=False):
+ def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, MacroDict=None, Flag=False):
Size = self.Size
+ if MacroDict is None:
+ MacroDict = {}
if not Flag:
GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' % self.Offset)
GenFdsGlobalVariable.InfLogger(" Region Size = 0x%X" % Size)
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py index b238956634..2acb70f412 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -92,7 +92,7 @@ class Section (SectionClassObject): # @param FfsInf FfsInfStatement object that contains this section data
# @param Dict dictionary contains macro and its value
#
- def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsInf = None, Dict = {}):
+ def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsInf = None, Dict = None):
pass
## GetFileList() method
diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source/Python/GenFds/UiSection.py index c9fc5997a1..f643058bd6 100644 --- a/BaseTools/Source/Python/GenFds/UiSection.py +++ b/BaseTools/Source/Python/GenFds/UiSection.py @@ -44,7 +44,7 @@ class UiSection (UiSectionClassObject): # @param Dict dictionary contains macro and its value
# @retval tuple (Generated file name, section alignment)
#
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile = False):
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile = False):
#
# Prepare the parameter of GenSection
#
@@ -58,6 +58,8 @@ class UiSection (UiSectionClassObject): if self.StringData is not None :
NameString = self.StringData
elif self.FileName is not None:
+ if Dict is None:
+ Dict = {}
FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)
FileObj = open(FileNameStr, 'r')
diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Source/Python/GenFds/VerSection.py index 1e7b391412..7280e80cb4 100644 --- a/BaseTools/Source/Python/GenFds/VerSection.py +++ b/BaseTools/Source/Python/GenFds/VerSection.py @@ -42,7 +42,7 @@ class VerSection (VerSectionClassObject): # @param Dict dictionary contains macro and its value
# @retval tuple (Generated file name, section alignment)
#
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile = False):
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile = False):
#
# Prepare the parameter of GenSection
#
@@ -61,6 +61,8 @@ class VerSection (VerSectionClassObject): if self.StringData:
StringData = self.StringData
elif self.FileName:
+ if Dict is None:
+ Dict = {}
FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)
FileObj = open(FileNameStr, 'r')
|