public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2-resend 1/1] BaseTools/Ecc: Make Ecc only check first include guard
@ 2021-03-15 20:33 PierreGondois
  2021-03-15 20:35 ` [edk2-devel] " PierreGondois
  2021-03-17  7:11 ` Bob Feng
  0 siblings, 2 replies; 3+ messages in thread
From: PierreGondois @ 2021-03-15 20:33 UTC (permalink / raw)
  To: devel, bob.c.feng, gaoliming, yuwei.chen

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_v2

Notes:
    v2:
     - Remove duplicated copyright.
     - Add Bob Feng's reviewed-by.
     - Add Liming Gao's reviewed-by (resend).

 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_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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH v2-resend 1/1] BaseTools/Ecc: Make Ecc only check first include guard
  2021-03-15 20:33 [PATCH v2-resend 1/1] BaseTools/Ecc: Make Ecc only check first include guard PierreGondois
@ 2021-03-15 20:35 ` PierreGondois
  2021-03-17  7:11 ` Bob Feng
  1 sibling, 0 replies; 3+ messages in thread
From: PierreGondois @ 2021-03-15 20:35 UTC (permalink / raw)
  To: PierreGondois, devel

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]

Re-sent because I forgot to add Liming's 'reviewd-by'.
Sorry for the spam.

Regards,
Pierre

[-- Attachment #2: Type: text/html, Size: 113 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2-resend 1/1] BaseTools/Ecc: Make Ecc only check first include guard
  2021-03-15 20:33 [PATCH v2-resend 1/1] BaseTools/Ecc: Make Ecc only check first include guard PierreGondois
  2021-03-15 20:35 ` [edk2-devel] " PierreGondois
@ 2021-03-17  7:11 ` Bob Feng
  1 sibling, 0 replies; 3+ messages in thread
From: Bob Feng @ 2021-03-17  7:11 UTC (permalink / raw)
  To: Pierre.Gondois@arm.com, devel@edk2.groups.io,
	gaoliming@byosoft.com.cn, Chen, Christine

Hi Pierre,

Could you recreate your patch and send again. On my machine, I can't apply this patch.

error: corrupt patch at line 33
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch

Thanks,
Bob

-----Original Message-----
From: Pierre.Gondois@arm.com <Pierre.Gondois@arm.com> 
Sent: Tuesday, March 16, 2021 4:34 AM
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 v2-resend 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_v2

Notes:
    v2:
     - Remove duplicated copyright.
     - Add Bob Feng's reviewed-by.
     - Add Liming Gao's reviewed-by (resend).

 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-17  7:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-15 20:33 [PATCH v2-resend 1/1] BaseTools/Ecc: Make Ecc only check first include guard PierreGondois
2021-03-15 20:35 ` [edk2-devel] " PierreGondois
2021-03-17  7:11 ` Bob Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox