* [PATCH v1 1/2] BaseTools: Fix crash in ECC when parsing incorrect header
2020-12-16 17:05 [PATCH v1 0/2] Ecc tool modifications PierreGondois
@ 2020-12-16 17:05 ` PierreGondois
2020-12-16 17:05 ` [PATCH v1 2/2] BaseTools/Ecc: Allow init of function static variables PierreGondois
2020-12-17 0:53 ` 回复: [PATCH v1 0/2] Ecc tool modifications gaoliming
2 siblings, 0 replies; 4+ messages in thread
From: PierreGondois @ 2020-12-16 17:05 UTC (permalink / raw)
To: devel, bob.c.feng, gaoliming, yuwei.chen; +Cc: sami.mujawar
From: Sami Mujawar <sami.mujawar@arm.com>
The ECC tool crashes if a C file has an incorrect file header
format.
The file ArmPkg\Library\ArmMmuLib\AArch64\ArmMmuPeiLibConstructor.c
has a file header in the incorrect format. It uses # to mark the
header comments instead of enclosing the file header in /* */. This
may have been a result of an INF file header being copied to a C
file.
A separate patch fixes the C file but ECC tool should
not crash if a file with an incorrect header is found.
Therefore, update the ECC tool to prevent it from crashing if an
incorrect file header is found. With this change the ECC tool will
report the incorrect header issue without crashing.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1551_Ecc_BaseTools_v1
BaseTools/Source/Python/Ecc/c.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py
index a30122a45f81..db686df0db25 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -2,6 +2,7 @@
# This file is used to be the c coding style checking of ECC tool
#
# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -64,7 +65,9 @@ def GetIdType(Str):
Type = DataClass.MODEL_UNKNOWN
Str = Str.replace('#', '# ')
List = Str.split()
- if List[1] == 'include':
+ if len(List) < 2:
+ pass
+ elif List[1] == 'include':
Type = DataClass.MODEL_IDENTIFIER_INCLUDE
elif List[1] == 'define':
Type = DataClass.MODEL_IDENTIFIER_MACRO_DEFINE
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 2/2] BaseTools/Ecc: Allow init of function static variables
2020-12-16 17:05 [PATCH v1 0/2] Ecc tool modifications PierreGondois
2020-12-16 17:05 ` [PATCH v1 1/2] BaseTools: Fix crash in ECC when parsing incorrect header PierreGondois
@ 2020-12-16 17:05 ` PierreGondois
2020-12-17 0:53 ` 回复: [PATCH v1 0/2] Ecc tool modifications gaoliming
2 siblings, 0 replies; 4+ messages in thread
From: PierreGondois @ 2020-12-16 17:05 UTC (permalink / raw)
To: devel, bob.c.feng, gaoliming, yuwei.chen; +Cc: sami.mujawar
From: Pierre Gondois <Pierre.Gondois@arm.com>
The Ecc tool currently reports the initialization of variables
at declaraton if the variable is non-constant and declared
in a function. Static variables locally defined in functions
should also be allowed to be initialized at declaration.
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1551_Ecc_BaseTools_v1
BaseTools/Source/Python/Ecc/c.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py
index db686df0db25..4a82e5e76003 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -1560,7 +1560,7 @@ def CheckFuncLayoutLocalVariable(FullFileName):
continue
for Result in ResultSet:
- if len(Result[1]) > 0 and 'CONST' not in Result[3]:
+ if len(Result[1]) > 0 and 'CONST' not in Result[3] and 'STATIC' not in Result[3]:
PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VARIABLE, 'Variable Name: %s' % Result[0], FileTable, Result[2])
def CheckMemberVariableFormat(Name, Value, FileTable, TdId, ModelId):
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* 回复: [PATCH v1 0/2] Ecc tool modifications
2020-12-16 17:05 [PATCH v1 0/2] Ecc tool modifications PierreGondois
2020-12-16 17:05 ` [PATCH v1 1/2] BaseTools: Fix crash in ECC when parsing incorrect header PierreGondois
2020-12-16 17:05 ` [PATCH v1 2/2] BaseTools/Ecc: Allow init of function static variables PierreGondois
@ 2020-12-17 0:53 ` gaoliming
2 siblings, 0 replies; 4+ messages in thread
From: gaoliming @ 2020-12-17 0:53 UTC (permalink / raw)
To: Pierre.Gondois, devel, bob.c.feng, yuwei.chen; +Cc: sami.mujawar
Pierre:
Thanks for your fix. The change is good. Reviewed-by: Liming Gao
<gaoliming@byosoft.com.cn>
Thanks
Liming
> -----邮件原件-----
> 发件人: Pierre.Gondois@arm.com <Pierre.Gondois@arm.com>
> 发送时间: 2020年12月17日 1:05
> 收件人: devel@edk2.groups.io; bob.c.feng@intel.com;
> gaoliming@byosoft.com.cn; yuwei.chen@intel.com
> 抄送: sami.mujawar@arm.com
> 主题: [PATCH v1 0/2] Ecc tool modifications
>
> From: Pierre Gondois <Pierre.Gondois@arm.com>
>
> While running the Ecc tool, some unexpected behaviors occurred.
> These patches aim to correct them.
>
> The changes can be seen at:
> https://github.com/PierreARM/edk2/commits/1551_Ecc_BaseTools_v1
>
> Pierre Gondois (1):
> BaseTools/Ecc: Allow init of function static variables
>
> Sami Mujawar (1):
> BaseTools: Fix crash in ECC when parsing incorrect header
>
> BaseTools/Source/Python/Ecc/c.py | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> --
> 2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread