]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions.
authorHess Chen <hesheng.chen@intel.com>
Wed, 17 Oct 2018 02:22:04 +0000 (10:22 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 24 Oct 2018 00:41:03 +0000 (08:41 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/Ecc/Check.py
BaseTools/Source/Python/Ecc/Configuration.py
BaseTools/Source/Python/Ecc/EccToolError.py
BaseTools/Source/Python/Ecc/config.ini

index fc86ad96f2cf2fbdfc388abd74d77db43e29fb5b..0491d2d4e4f13843e0918758fa27fd14babd2f33 100644 (file)
@@ -270,6 +270,66 @@ class Check(object):
         self.FunctionLayoutCheckPrototype()\r
         self.FunctionLayoutCheckBody()\r
         self.FunctionLayoutCheckLocalVariable()\r
+        self.FunctionLayoutCheckDeprecated()\r
+    \r
+    # To check if the deprecated functions are used\r
+    def FunctionLayoutCheckDeprecated(self):\r
+        if EccGlobalData.gConfig.CFunctionLayoutCheckNoDeprecated == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
+            EdkLogger.quiet("Checking function no deprecated one being used ...")\r
+\r
+            DeprecatedFunctionSet = ('UnicodeValueToString',\r
+                                     'AsciiValueToString',\r
+                                     'StrCpy',\r
+                                     'StrnCpy',\r
+                                     'StrCat',\r
+                                     'StrnCat',\r
+                                     'UnicodeStrToAsciiStr',\r
+                                     'AsciiStrCpy',\r
+                                     'AsciiStrnCpy',\r
+                                     'AsciiStrCat',\r
+                                     'AsciiStrnCat',\r
+                                     'AsciiStrToUnicodeStr',\r
+                                     'PcdSet8',\r
+                                     'PcdSet16',\r
+                                     'PcdSet32',\r
+                                     'PcdSet64',\r
+                                     'PcdSetPtr',\r
+                                     'PcdSetBool',\r
+                                     'PcdSetEx8',\r
+                                     'PcdSetEx16',\r
+                                     'PcdSetEx32',\r
+                                     'PcdSetEx64',\r
+                                     'PcdSetExPtr',\r
+                                     'PcdSetExBool',\r
+                                     'LibPcdSet8',\r
+                                     'LibPcdSet16',\r
+                                     'LibPcdSet32',\r
+                                     'LibPcdSet64',\r
+                                     'LibPcdSetPtr',\r
+                                     'LibPcdSetBool',\r
+                                     'LibPcdSetEx8',\r
+                                     'LibPcdSetEx16',\r
+                                     'LibPcdSetEx32',\r
+                                     'LibPcdSetEx64',\r
+                                     'LibPcdSetExPtr',\r
+                                     'LibPcdSetExBool',\r
+                                     'GetVariable',\r
+                                     'GetEfiGlobalVariable',\r
+                                     )\r
+\r
+            for IdentifierTable in EccGlobalData.gIdentifierTableList:\r
+                SqlCommand = """select ID, Name, BelongsToFile from %s\r
+                                where Model = %s """ % (IdentifierTable, MODEL_IDENTIFIER_FUNCTION_CALLING)\r
+                RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
+                for Record in RecordSet:\r
+                    for Key in DeprecatedFunctionSet:\r
+                        if Key == Record[1]:\r
+                            if not EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE, Key):\r
+                                OtherMsg = 'The function [%s] is deprecated which should NOT be used' % Key\r
+                                EccGlobalData.gDb.TblReport.Insert(ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE,\r
+                                                                   OtherMsg=OtherMsg,\r
+                                                                   BelongsToTable=IdentifierTable,\r
+                                                                   BelongsToItem=Record[0])\r
 \r
     def WalkTree(self):\r
         IgnoredPattern = c.GetIgnoredDirListPattern()\r
index c19a3990c74e113855d37747f2f4dc4bdc9efca7..8f6886169c7c0081383eda06223da3daf8ffee47 100644 (file)
@@ -34,6 +34,7 @@ _ConfigFileToInternalTranslation = {
     "CFunctionLayoutCheckFunctionBody":"CFunctionLayoutCheckFunctionBody",\r
     "CFunctionLayoutCheckFunctionName":"CFunctionLayoutCheckFunctionName",\r
     "CFunctionLayoutCheckFunctionPrototype":"CFunctionLayoutCheckFunctionPrototype",\r
+    "CFunctionLayoutCheckNoDeprecated":"CFunctionLayoutCheckNoDeprecated",\r
     "CFunctionLayoutCheckNoInitOfVariable":"CFunctionLayoutCheckNoInitOfVariable",\r
     "CFunctionLayoutCheckNoStatic":"CFunctionLayoutCheckNoStatic",\r
     "CFunctionLayoutCheckOptionalFunctionalModifier":"CFunctionLayoutCheckOptionalFunctionalModifier",\r
@@ -242,6 +243,8 @@ class Configuration(object):
         self.CFunctionLayoutCheckNoInitOfVariable = 1\r
         # Check whether no use of STATIC for functions\r
         self.CFunctionLayoutCheckNoStatic = 1\r
+        # Check whether no use of Deprecated functions\r
+        self.CFunctionLayoutCheckNoDeprecated = 1\r
 \r
         ## Include Files Checking\r
         self.IncludeFileCheckAll = 0\r
index ae0a31af8a8c1c10173a6ec9c8ecf7a55df3a95d..74f06bc4907f63311658012a6dafa7b8d243ac4d 100644 (file)
@@ -47,6 +47,7 @@ ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VARIABLE = 5007
 ERROR_C_FUNCTION_LAYOUT_CHECK_NO_STATIC = 5008\r
 ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_2 = 5009\r
 ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_3 = 5010\r
+ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE = 5011\r
 \r
 ERROR_INCLUDE_FILE_CHECK_ALL = 6000\r
 ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1 = 6001\r
@@ -146,6 +147,7 @@ gEccErrorMessage = {
     ERROR_C_FUNCTION_LAYOUT_CHECK_DATA_DECLARATION : "The data declarations should be the first code in a module",\r
     ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VARIABLE : "There should be no initialization of a variable as part of its declaration",\r
     ERROR_C_FUNCTION_LAYOUT_CHECK_NO_STATIC : "There should be no use of STATIC for functions",\r
+    ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE : "The deprecated function should NOT be used",\r
 \r
     ERROR_INCLUDE_FILE_CHECK_ALL : "",\r
     ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1 : "All include file contents should be guarded by a #ifndef statement.",\r
index 00c98c6232d78e2c1b95116da4d14f1d0d66c092..663ae293bd028f278a8f79528e4eb2ed3922d7e8 100644 (file)
@@ -134,6 +134,8 @@ CFunctionLayoutCheckDataDeclaration = 1
 CFunctionLayoutCheckNoInitOfVariable = 1\r
 # Check whether no use of STATIC for functions\r
 CFunctionLayoutCheckNoStatic = 1\r
+# Check whether no use of Deprecated functions\r
+CFunctionLayoutCheckNoDeprecated  = 1\r
 \r
 #\r
 # Include Files Checking\r