Re: [edk2] [PATCH] BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions.
Good suggestion, will update the patch. Chen, Hess Intel China Software Center Tel: +86-21-6116-6740 Email: hesheng.c...@intel.com -Original Message- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Carsey, Jaben Sent: Wednesday, October 17, 2018 11:49 PM To: Zhu, Yonghong Cc: edk2-devel@lists.01.org; Chen, Hesheng Subject: Re: [edk2] [PATCH] BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions. Propose to use a set not a list when the data is unordered and unique names of functions. With that: reviewed-by:Jaben.carsey Sent from my iPad > On Oct 16, 2018, at 7:25 PM, Yonghong Zhu wrote: > > From: Hess Chen > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hess Chen > --- > BaseTools/Source/Python/Ecc/Check.py | 60 > BaseTools/Source/Python/Ecc/Configuration.py | 3 ++ > BaseTools/Source/Python/Ecc/EccToolError.py | 2 + > BaseTools/Source/Python/Ecc/config.ini | 2 + > 4 files changed, 67 insertions(+) > > diff --git a/BaseTools/Source/Python/Ecc/Check.py > b/BaseTools/Source/Python/Ecc/Check.py > index eb086362bd..3baf81fa44 100644 > --- a/BaseTools/Source/Python/Ecc/Check.py > +++ b/BaseTools/Source/Python/Ecc/Check.py > @@ -270,6 +270,66 @@ class Check(object): > self.FunctionLayoutCheckPrototype() > self.FunctionLayoutCheckBody() > self.FunctionLayoutCheckLocalVariable() > +self.FunctionLayoutCheckDeprecated() > + > +# To check if the deprecated functions are used > +def FunctionLayoutCheckDeprecated(self): > +if EccGlobalData.gConfig.CFunctionLayoutCheckNoDeprecated == '1' or > EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or > EccGlobalData.gConfig.CheckAll == '1': > +EdkLogger.quiet("Checking function no deprecated one > + being used ...") > + > +DeprecatedFunctionList = ['UnicodeValueToString', > + 'AsciiValueToString', > + 'StrCpy', > + 'StrnCpy', > + 'StrCat', > + 'StrnCat', > + 'UnicodeStrToAsciiStr', > + 'AsciiStrCpy', > + 'AsciiStrnCpy', > + 'AsciiStrCat', > + 'AsciiStrnCat', > + 'AsciiStrToUnicodeStr', > + 'PcdSet8', > + 'PcdSet16', > + 'PcdSet32', > + 'PcdSet64', > + 'PcdSetPtr', > + 'PcdSetBool', > + 'PcdSetEx8', > + 'PcdSetEx16', > + 'PcdSetEx32', > + 'PcdSetEx64', > + 'PcdSetExPtr', > + 'PcdSetExBool', > + 'LibPcdSet8', > + 'LibPcdSet16', > + 'LibPcdSet32', > + 'LibPcdSet64', > + 'LibPcdSetPtr', > + 'LibPcdSetBool', > + 'LibPcdSetEx8', > + 'LibPcdSetEx16', > + 'LibPcdSetEx32', > + 'LibPcdSetEx64', > + 'LibPcdSetExPtr', > + 'LibPcdSetExBool', > + 'GetVariable', > + 'GetEfiGlobalVariable', > + ] > + > +for IdentifierTable in EccGlobalData.gIdentifierTableList: > +SqlCommand = """select ID, Name, BelongsToFile from %s > +whe
Re: [edk2] [PATCH] BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions.
Propose to use a set not a list when the data is unordered and unique names of functions. With that: reviewed-by:Jaben.carsey Sent from my iPad > On Oct 16, 2018, at 7:25 PM, Yonghong Zhu wrote: > > From: Hess Chen > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hess Chen > --- > BaseTools/Source/Python/Ecc/Check.py | 60 > BaseTools/Source/Python/Ecc/Configuration.py | 3 ++ > BaseTools/Source/Python/Ecc/EccToolError.py | 2 + > BaseTools/Source/Python/Ecc/config.ini | 2 + > 4 files changed, 67 insertions(+) > > diff --git a/BaseTools/Source/Python/Ecc/Check.py > b/BaseTools/Source/Python/Ecc/Check.py > index eb086362bd..3baf81fa44 100644 > --- a/BaseTools/Source/Python/Ecc/Check.py > +++ b/BaseTools/Source/Python/Ecc/Check.py > @@ -270,6 +270,66 @@ class Check(object): > self.FunctionLayoutCheckPrototype() > self.FunctionLayoutCheckBody() > self.FunctionLayoutCheckLocalVariable() > +self.FunctionLayoutCheckDeprecated() > + > +# To check if the deprecated functions are used > +def FunctionLayoutCheckDeprecated(self): > +if EccGlobalData.gConfig.CFunctionLayoutCheckNoDeprecated == '1' or > EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or > EccGlobalData.gConfig.CheckAll == '1': > +EdkLogger.quiet("Checking function no deprecated one being used > ...") > + > +DeprecatedFunctionList = ['UnicodeValueToString', > + 'AsciiValueToString', > + 'StrCpy', > + 'StrnCpy', > + 'StrCat', > + 'StrnCat', > + 'UnicodeStrToAsciiStr', > + 'AsciiStrCpy', > + 'AsciiStrnCpy', > + 'AsciiStrCat', > + 'AsciiStrnCat', > + 'AsciiStrToUnicodeStr', > + 'PcdSet8', > + 'PcdSet16', > + 'PcdSet32', > + 'PcdSet64', > + 'PcdSetPtr', > + 'PcdSetBool', > + 'PcdSetEx8', > + 'PcdSetEx16', > + 'PcdSetEx32', > + 'PcdSetEx64', > + 'PcdSetExPtr', > + 'PcdSetExBool', > + 'LibPcdSet8', > + 'LibPcdSet16', > + 'LibPcdSet32', > + 'LibPcdSet64', > + 'LibPcdSetPtr', > + 'LibPcdSetBool', > + 'LibPcdSetEx8', > + 'LibPcdSetEx16', > + 'LibPcdSetEx32', > + 'LibPcdSetEx64', > + 'LibPcdSetExPtr', > + 'LibPcdSetExBool', > + 'GetVariable', > + 'GetEfiGlobalVariable', > + ] > + > +for IdentifierTable in EccGlobalData.gIdentifierTableList: > +SqlCommand = """select ID, Name, BelongsToFile from %s > +where Model = %s """ % (IdentifierTable, > MODEL_IDENTIFIER_FUNCTION_CALLING) > +RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand) > +for Record in RecordSet: > +for Key in DeprecatedFunctionList: > +if Key == Record[1]: > +if not > EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE, > Key): > +OtherMsg = 'The function [%s] is deprecated > which should NOT be used' % Key > + > EccGlobalData.gDb.TblReport.Insert(ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE, > + > OtherMsg=OtherMsg, > + > BelongsToTable=IdentifierTable, > + > BelongsToItem=Record[0]) > > def WalkTree(self): > IgnoredPattern = c.GetIgnoredDirListPattern() > diff --git a/BaseTools/Source/Python/Ecc/Configuration.py > b/BaseTools/Source/Python/Ecc/Configuration.py > index c19a3990c7..8f68861
[edk2] [PATCH] BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions.
From: Hess Chen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen --- BaseTools/Source/Python/Ecc/Check.py | 60 BaseTools/Source/Python/Ecc/Configuration.py | 3 ++ BaseTools/Source/Python/Ecc/EccToolError.py | 2 + BaseTools/Source/Python/Ecc/config.ini | 2 + 4 files changed, 67 insertions(+) diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py index eb086362bd..3baf81fa44 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -270,6 +270,66 @@ class Check(object): self.FunctionLayoutCheckPrototype() self.FunctionLayoutCheckBody() self.FunctionLayoutCheckLocalVariable() +self.FunctionLayoutCheckDeprecated() + +# To check if the deprecated functions are used +def FunctionLayoutCheckDeprecated(self): +if EccGlobalData.gConfig.CFunctionLayoutCheckNoDeprecated == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1': +EdkLogger.quiet("Checking function no deprecated one being used ...") + +DeprecatedFunctionList = ['UnicodeValueToString', + 'AsciiValueToString', + 'StrCpy', + 'StrnCpy', + 'StrCat', + 'StrnCat', + 'UnicodeStrToAsciiStr', + 'AsciiStrCpy', + 'AsciiStrnCpy', + 'AsciiStrCat', + 'AsciiStrnCat', + 'AsciiStrToUnicodeStr', + 'PcdSet8', + 'PcdSet16', + 'PcdSet32', + 'PcdSet64', + 'PcdSetPtr', + 'PcdSetBool', + 'PcdSetEx8', + 'PcdSetEx16', + 'PcdSetEx32', + 'PcdSetEx64', + 'PcdSetExPtr', + 'PcdSetExBool', + 'LibPcdSet8', + 'LibPcdSet16', + 'LibPcdSet32', + 'LibPcdSet64', + 'LibPcdSetPtr', + 'LibPcdSetBool', + 'LibPcdSetEx8', + 'LibPcdSetEx16', + 'LibPcdSetEx32', + 'LibPcdSetEx64', + 'LibPcdSetExPtr', + 'LibPcdSetExBool', + 'GetVariable', + 'GetEfiGlobalVariable', + ] + +for IdentifierTable in EccGlobalData.gIdentifierTableList: +SqlCommand = """select ID, Name, BelongsToFile from %s +where Model = %s """ % (IdentifierTable, MODEL_IDENTIFIER_FUNCTION_CALLING) +RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand) +for Record in RecordSet: +for Key in DeprecatedFunctionList: +if Key == Record[1]: +if not EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE, Key): +OtherMsg = 'The function [%s] is deprecated which should NOT be used' % Key + EccGlobalData.gDb.TblReport.Insert(ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE, + OtherMsg=OtherMsg, + BelongsToTable=IdentifierTable, + BelongsToItem=Record[0]) def WalkTree(self): IgnoredPattern = c.GetIgnoredDirListPattern() diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/Source/Python/Ecc/Configuration.py index c19a3990c7..8f6886169c 100644 --- a/BaseTools/Source/Python/Ecc/Configuration.py +++ b/BaseTools/Source/Python/Ecc/Configuration.py @@ -34,6 +34,7 @@ _ConfigFileToInternalTranslation = { "CFunctionLayoutCheckFunctionBody":"CFunctionLayoutCheckFunctionBody", "CFunctionLayoutCheckFunctionName":"CFunctionLayoutCheckFunctionName", "CFunctionLayoutCheckFunctionPrototype":"CFunctionLayoutCheck