]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Ecc/c.py
BaseTools/Ecc: Remove checkpoint for STATIC modifier
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / c.py
index ea7d99fecd22186bf7fd27118dee2b18845755c1..256b9e021c265d5a12a74b8fe32114873c720f11 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to be the c coding style checking of ECC tool\r
 #\r
-# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -12,7 +12,7 @@
 #\r
 \r
 import sys\r
-import os\r
+import Common.LongFilePathOs as os\r
 import re\r
 import string\r
 import CodeFragmentCollector\r
@@ -514,6 +514,8 @@ def CollectSourceCodeDataIntoDB(RootDir):
                     dirnames.append(Dirname)\r
 \r
         for f in filenames:\r
+            if f.lower() in EccGlobalData.gConfig.SkipFileList:\r
+                continue\r
             collector = None\r
             FullName = os.path.normpath(os.path.join(dirpath, f))\r
             model = DataClass.MODEL_FILE_OTHERS\r
@@ -1170,6 +1172,8 @@ def GetVarInfo(PredVarList, FuncRecord, FullFileName, IsFuncCall=False, TargetTy
             else:\r
                 TypeList = GetDataTypeFromModifier(Param.Modifier).split()\r
                 Type = TypeList[-1]\r
+                if Type == '*' and len(TypeList) >= 2:\r
+                    Type = TypeList[-2]\r
                 if len(TypeList) > 1 and StarList != None:\r
                     for Star in StarList:\r
                         Type = Type.strip()\r
@@ -1267,7 +1271,10 @@ def CheckFuncLayoutReturnType(FullFileName):
         FuncName = Result[5]\r
         if EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, FuncName):\r
             continue\r
-        Index = Result[0].find(TypeStart)\r
+        Result0 = Result[0]\r
+        if Result0.upper().startswith('STATIC'):\r
+            Result0 = Result0[6:].strip()\r
+        Index = Result0.find(TypeStart)\r
         if Index != 0 or Result[3] != 0:\r
             PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, '[%s] Return Type should appear at the start of line' % FuncName, FileTable, Result[1])\r
 \r
@@ -1285,13 +1292,13 @@ def CheckFuncLayoutReturnType(FullFileName):
         FuncName = Result[5]\r
         if EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, FuncName):\r
             continue\r
-        Index = Result[0].find(ReturnType)\r
+        Result0 = Result[0]\r
+        if Result0.upper().startswith('STATIC'):\r
+            Result0 = Result0[6:].strip()\r
+        Index = Result0.find(ReturnType)\r
         if Index != 0 or Result[3] != 0:\r
             PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, '[%s] Return Type should appear at the start of line' % FuncName, 'Function', Result[1])\r
 \r
-        if Result[2] == Result[4]:\r
-            PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, '[%s] Return Type should appear on its own line' % FuncName, 'Function', Result[1])\r
-\r
 def CheckFuncLayoutModifier(FullFileName):\r
     ErrorMsgList = []\r
 \r
@@ -1309,9 +1316,10 @@ def CheckFuncLayoutModifier(FullFileName):
     for Result in ResultSet:\r
         ReturnType = GetDataTypeFromModifier(Result[0])\r
         TypeStart = ReturnType.split()[0]\r
-#        if len(ReturnType) == 0:\r
-#            continue\r
-        Index = Result[0].find(TypeStart)\r
+        Result0 = Result[0]\r
+        if Result0.upper().startswith('STATIC'):\r
+            Result0 = Result0[6:].strip()\r
+        Index = Result0.find(TypeStart)\r
         if Index != 0:\r
             PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_OPTIONAL_FUNCTIONAL_MODIFIER, '', FileTable, Result[1])\r
 \r
@@ -1323,9 +1331,10 @@ def CheckFuncLayoutModifier(FullFileName):
     for Result in ResultSet:\r
         ReturnType = GetDataTypeFromModifier(Result[0])\r
         TypeStart = ReturnType.split()[0]\r
-#        if len(ReturnType) == 0:\r
-#            continue\r
-        Index = Result[0].find(TypeStart)\r
+        Result0 = Result[0]\r
+        if Result0.upper().startswith('STATIC'):\r
+            Result0 = Result0[6:].strip()\r
+        Index = Result0.find(TypeStart)\r
         if Index != 0:\r
             PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_OPTIONAL_FUNCTIONAL_MODIFIER, '', 'Function', Result[1])\r
 \r
@@ -1624,12 +1633,17 @@ def CheckMemberVariableFormat(Name, Value, FileTable, TdId, ModelId):
         Field = Field.strip()\r
         if Field == '':\r
             continue\r
+        if Field.startswith("#"):\r
+            continue\r
         # Enum could directly assign value to variable\r
         Field = Field.split('=')[0].strip()\r
         TokenList = Field.split()\r
         # Remove pointers before variable\r
-        if not Pattern.match(TokenList[-1].lstrip('*')):\r
-            ErrMsgList.append(TokenList[-1].lstrip('*'))\r
+        Token = TokenList[-1]\r
+        if Token in ['OPTIONAL']:\r
+            Token = TokenList[-2]\r
+        if not Pattern.match(Token.lstrip('*')):\r
+            ErrMsgList.append(Token.lstrip('*'))\r
 \r
     return ErrMsgList\r
 \r
@@ -2357,7 +2371,10 @@ def CheckFileHeaderDoxygenComments(FullFileName):
             if CommentLine.startswith('Copyright'):\r
                 NoCopyrightFlag = False\r
                 if CommentLine.find('All rights reserved') == -1:\r
-                    PrintErrorMsg(ERROR_HEADER_CHECK_FILE, '""All rights reserved"" announcement should be following the ""Copyright"" at the same line', FileTable, ID)\r
+                    for Copyright in EccGlobalData.gConfig.Copyright:\r
+                        if CommentLine.find(Copyright) > -1:\r
+                            PrintErrorMsg(ERROR_HEADER_CHECK_FILE, '""All rights reserved"" announcement should be following the ""Copyright"" at the same line', FileTable, ID)\r
+                            break\r
                 if CommentLine.endswith('<BR>') == -1:\r
                     PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'The ""<BR>"" at the end of the Copyright line is required', FileTable, ID)\r
                 if NextLineIndex < len(CommentStrList) and CommentStrList[NextLineIndex].strip().startswith('Copyright') == False and CommentStrList[NextLineIndex].strip():\r