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>
This commit is contained in:
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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:
|
||||
|
@@ -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);
|
||||
|
@@ -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.
|
||||
|
@@ -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 :
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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:
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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')
|
||||
|
@@ -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')
|
||||
|
Reference in New Issue
Block a user