From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.11513.1615306659452305213 for ; Tue, 09 Mar 2021 08:17:39 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B842C1042; Tue, 9 Mar 2021 08:17:36 -0800 (PST) Received: from e120189.arm.com (unknown [10.57.49.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4EE823F71B; Tue, 9 Mar 2021 08:17:35 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io, bob.c.feng@intel.com, gaoliming@byosoft.com.cn, yuwei.chen@intel.com Subject: [PATCH v1 1/1] BaseTools/Ecc: Make Ecc only check first include guard Date: Tue, 9 Mar 2021 16:17:28 +0000 Message-Id: <20210309161728.13820-1-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.17.1 From: Pierre Gondois 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 --- The changes can be seen at: https://github.com/PierreARM/edk2/tree/1640_Ecc_tool_corrections BaseTools/Source/Python/Ecc/Check.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py index 7a012617fd35..d82b42de0119 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -3,6 +3,7 @@ # # Copyright (c) 2021, Arm Limited. All rights reserved.
# Copyright (c) 2008 - 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2021, Arm Limited. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # from __future__ import absolute_import @@ -1437,11 +1438,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 -- 2.17.1