public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Bob Feng" <bob.c.feng@intel.com>
To: "Pierre.Gondois@arm.com" <Pierre.Gondois@arm.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"gaoliming@byosoft.com.cn" <gaoliming@byosoft.com.cn>,
	"Chen, Christine" <yuwei.chen@intel.com>
Subject: Re: [PATCH v3 1/1] BaseTools/Ecc: Make Ecc only check first include guard
Date: Thu, 18 Mar 2021 01:34:04 +0000	[thread overview]
Message-ID: <DM6PR11MB4073A321AFF2F7957530ECA6C9699@DM6PR11MB4073.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20210317095937.26869-1-Pierre.Gondois@arm.com>

Create a PR https://github.com/tianocore/edk2/pull/1500

Thanks,
Bob

-----Original Message-----
From: Pierre.Gondois@arm.com <Pierre.Gondois@arm.com> 
Sent: Wednesday, March 17, 2021 6:00 PM
To: devel@edk2.groups.io; Feng, Bob C <bob.c.feng@intel.com>; gaoliming@byosoft.com.cn; Chen, Christine <yuwei.chen@intel.com>
Subject: [PATCH v3 1/1] BaseTools/Ecc: Make Ecc only check first include guard

From: Pierre Gondois <Pierre.Gondois@arm.com>

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>
---
The changes can be seen at: https://github.com/PierreARM/edk2/tree/1640_Ecc_tool_corrections_v3

Notes:
    v2:
     - Remove duplicated copyright.
     - Add Bob Feng's reviewed-by.
     - Add Liming Gao's reviewed-by (resend).
    
    v3:
     - Correct bad formatting of patch
       (not-possible to apply the patch). [Bob]

 BaseTools/Source/Python/Ecc/Check.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py
index 7a012617fd35..33060db5f27a 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_IFNDE
+ F_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


      reply	other threads:[~2021-03-18  1:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17  9:59 [PATCH v3 1/1] BaseTools/Ecc: Make Ecc only check first include guard PierreGondois
2021-03-18  1:34 ` Bob Feng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM6PR11MB4073A321AFF2F7957530ECA6C9699@DM6PR11MB4073.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox