BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1523

When the keyword after @param doesn't match the actual function
parameter name, ECC doesn't detect such issue

The patch is going to fix this issue

Cc: Liming Gao <liming....@intel.com>
Cc: Bob Feng <bob.c.f...@intel.com>
Signed-off-by: Zhiju.Fan <zhijux....@intel.com>
---

Optimize the code to Give the CheckParamName function
an explicit return value

 BaseTools/Source/Python/Ecc/c.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py
index a30122a45f..d21ea2b7a3 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -2554,6 +2554,22 @@ def CheckGeneralDoxygenCommentLayout(Str, StartLine, 
ErrorMsgList, CommentId= -1
         ErrorMsgList.append('Line %d : @retval appear before @param ' % 
StartLine)
         PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in Comment, 
@retval appear before @param  ', TableName, CommentId)
 
+def CheckParamName(ParamName, Tag):
+    ParamList = Tag.split()
+    if len(ParamList) > 1:
+        ParamList[0] = ParamList[0].replace('@param', '')
+        for Item in ParamList:
+            if Item.find('[') > 0 and Item.find(']') > 0:
+                continue
+            if ParamName != Item.strip():
+                return True
+            else:
+                return False
+        else:
+            return True
+    else:
+        return True
+
 def CheckFunctionHeaderConsistentWithDoxygenComment(FuncModifier, FuncHeader, 
FuncStartLine, CommentStr, CommentStartLine, ErrorMsgList, CommentId= -1, 
TableName=''):
 
     ParamList = GetParamList(FuncHeader)
@@ -2608,7 +2624,7 @@ def 
CheckFunctionHeaderConsistentWithDoxygenComment(FuncModifier, FuncHeader, Fu
                                 
PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in Comment, <%s> does NOT 
have %s ' % ((TagPartList[0] + ' ' + TagPartList[1]).replace('\n', 
'').replace('\r', ''), '[' + InOutStr + ']'), TableName, CommentId)
 
 
-            if Tag.find(ParamName) == -1 and ParamName != 'VOID' and ParamName 
!= 'void':
+            if (Tag.find(ParamName) == -1 or CheckParamName(ParamName, Tag)) 
and ParamName != 'VOID' and ParamName != 'void':
                 ErrorMsgList.append('Line %d : in Comment, <%s> does NOT 
consistent with parameter name %s ' % (CommentStartLine, (TagPartList[0] + ' ' 
+ TagPartList[1]).replace('\n', '').replace('\r', ''), ParamName))
                 PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in 
Comment, <%s> does NOT consistent with parameter name %s ' % ((TagPartList[0] + 
' ' + TagPartList[1]).replace('\n', '').replace('\r', ''), ParamName), 
TableName, CommentId)
             Index += 1
-- 
2.14.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#53424): https://edk2.groups.io/g/devel/message/53424
Mute This Topic: https://groups.io/mt/69952600/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

<<attachment: winmail.dat>>

Reply via email to