From 33a211d0095575b35cba16a1a8c305588bf1d49a Mon Sep 17 00:00:00 2001 From: Hess Chen Date: Wed, 17 Oct 2018 10:22:04 +0800 Subject: BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen Reviewed-by: Yonghong Zhu --- BaseTools/Source/Python/Ecc/Check.py | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'BaseTools/Source/Python/Ecc/Check.py') diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py index fc86ad96f2..0491d2d4e4 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 ...") + + DeprecatedFunctionSet = ('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 DeprecatedFunctionSet: + 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() -- cgit v1.2.3