summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/Ecc/Check.py
diff options
context:
space:
mode:
authorPierre Gondois <Pierre.Gondois@arm.com>2021-02-16 17:29:07 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-02-26 05:40:32 +0000
commit6ffbb3581ab7c25a35041bac03b760af54f852bf (patch)
treeef013e4aa41975b304382f60954a2687430f1e9b /BaseTools/Source/Python/Ecc/Check.py
parent7f34681c488aee2563eaa2afcc6a2c8aa7c5b912 (diff)
downloadedk2-6ffbb3581ab7c25a35041bac03b760af54f852bf.tar.gz
edk2-6ffbb3581ab7c25a35041bac03b760af54f852bf.tar.bz2
edk2-6ffbb3581ab7c25a35041bac03b760af54f852bf.zip
BaseTools: Align include guards policy
The EDK II C Coding Standards Specification states that: "Names starting with one or two underscores, such as _MACRO_GUARD_FILE_NAME_H_, must not be used. They are reserved for compiler implementation." [1] The Ecc tool currently checks that the include guard end with a trailing underscore. Thus, the check and the error message should both be modified. The new check forces having one sole trailing underscore character, as the example in the specification shows: "FILE_NAME_H_" [1] This would allow to have more consistency. [1] Section 5.3.5 "All include file contents must be protected by a #include guard": https://edk2-docs.gitbook.io/ edk-ii-c-coding-standards-specification/5_source_files/53_include_files Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <Sami.Mujawar@arm.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'BaseTools/Source/Python/Ecc/Check.py')
-rw-r--r--BaseTools/Source/Python/Ecc/Check.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py
index 6087abfa4d..7a012617fd 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -1,6 +1,7 @@
## @file
# This file is used to define checkpoints used by ECC tool
#
+# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
# Copyright (c) 2008 - 2020, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -1438,7 +1439,7 @@ class Check(object):
RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
for Record in RecordSet:
Name = Record[1].replace('#ifndef', '').strip()
- if Name[-1] != '_':
+ 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])