summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
authorPierre Gondois <Pierre.Gondois@arm.com>2021-03-17 17:59:37 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-03-18 02:04:18 +0000
commitce6c2b0016c2f68b6008acea1f24ed966b647147 (patch)
tree1e4db648585f633a3ee74083f1fba653aab3f8a0 /BaseTools
parent313d86c956d4599054a9dcd524668f67797d317a (diff)
downloadedk2-ce6c2b0016c2f68b6008acea1f24ed966b647147.tar.gz
edk2-ce6c2b0016c2f68b6008acea1f24ed966b647147.tar.bz2
edk2-ce6c2b0016c2f68b6008acea1f24ed966b647147.zip
BaseTools/Ecc: Make Ecc only check first include guard
The Ecc tool checks the format of the include guard. This check is currently done on all the names following the '#ifndef' statement. It should only be done on the first include guard. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3252 Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/Python/Ecc/Check.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py
index 7a012617fd..33060db5f2 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -1437,11 +1437,13 @@ class Check(object):
SqlCommand = """select ID, Value from %s where Model = %s""" % (FileTable, MODEL_IDENTIFIER_MACRO_IFNDEF)
RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
- for Record in RecordSet:
- Name = Record[1].replace('#ifndef', '').strip()
+ if RecordSet:
+ # Only check the first ifndef statement of the file
+ FirstDefine = sorted(RecordSet, key=lambda Record: Record[0])[0]
+ Name = FirstDefine[1].replace('#ifndef', '').strip()
if Name[0] == '_' or Name[-1] != '_' or Name[-2] == '_':
if not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHECK_IFNDEF_STATEMENT, Name):
- EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_IFNDEF_STATEMENT, OtherMsg="The #ifndef name [%s] does not follow the rules" % (Name), BelongsToTable=FileTable, BelongsToItem=Record[0])
+ EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_IFNDEF_STATEMENT, OtherMsg="The #ifndef name [%s] does not follow the rules" % (Name), BelongsToTable=FileTable, BelongsToItem=FirstDefine[0])
# Rule for path name, variable name and function name
# 1. First character should be upper case