From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web11.6128.1611624136186104287 for ; Mon, 25 Jan 2021 17:22:17 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Tue, 26 Jan 2021 09:22:05 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , , Cc: , , "'Laszlo Ersek'" , "'Michael D Kinney'" , "'Andrew Fish'" References: <20210125154525.18449-1-Pierre.Gondois@arm.com> In-Reply-To: <20210125154525.18449-1-Pierre.Gondois@arm.com> Subject: =?UTF-8?B?5Zue5aSNOiBbUEFUQ0ggdjEgMS8xXSBCYXNlVG9vbHM6IEFsaWduIGluY2x1ZGUgZ3VhcmRzIHBvbGljeQ==?= Date: Tue, 26 Jan 2021 09:22:06 +0800 Message-ID: <00f201d6f381$a8dd8970$fa989c50$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQGlA7GGrJ2S6a9oLVPP+lkyZnS4mKqc9rZQ Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Pierre: There are some discussion on the syntax of the header file macro. I suggest we align the syntax first, then add this checker in ECC tool.=20 In MdePkg, there are 555 header files. 70% header files use the style __BASE_H__ as the file header macro. Others use the style _BTT_H_.=20 For this case, I would propose to update EDK II C Coding Standards Specification to align the code.=20 =20 Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: Pierre.Gondois@arm.com > =B7=A2=CB=CD=CA=B1=BC=E4: 2021=C4=EA1=D4=C225=C8=D5 23:45 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io; bob.c.feng@intel.com; > gaoliming@byosoft.com.cn > =B3=AD=CB=CD: sami.mujawar@arm.com > =D6=F7=CC=E2: [PATCH v1 1/1] BaseTools: Align include guards policy >=20 > From: Pierre Gondois >=20 > 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] >=20 > 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. >=20 > 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. >=20 > [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 >=20 > Signed-off-by: Pierre Gondois > --- > BaseTools/Source/Python/Ecc/Check.py | 3 ++- > BaseTools/Source/Python/Ecc/EccToolError.py | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/Ecc/Check.py > b/BaseTools/Source/Python/Ecc/Check.py > index 6087abfa4d8d..14759d21f5d8 100644 > --- a/BaseTools/Source/Python/Ecc/Check.py > +++ b/BaseTools/Source/Python/Ecc/Check.py > @@ -2,6 +2,7 @@ > # This file is used to define checkpoints used by ECC tool > # > # 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 > @@ -1438,7 +1439,7 @@ class Check(object): > RecordSet =3D EccGlobalData.gDb.TblFile.Exec(SqlCommand) > for Record in RecordSet: > Name =3D Record[1].replace('#ifndef', '').strip() > - if Name[-1] !=3D '_': > + if Name[0] =3D=3D '_' or Name[-1] !=3D '_' or = Name[-2] =3D=3D '_': > if not > EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHE > CK_IFNDEF_STATEMENT, Name): >=20 > EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK > _IFNDEF_STATEMENT, OtherMsg=3D"The #ifndef name [%s] does not follow = the > rules" % (Name), BelongsToTable=3DFileTable, = BelongsToItem=3DRecord[0]) >=20 > diff --git a/BaseTools/Source/Python/Ecc/EccToolError.py > b/BaseTools/Source/Python/Ecc/EccToolError.py > index 0ff3b42674d4..58d0749477b2 100644 > --- a/BaseTools/Source/Python/Ecc/EccToolError.py > +++ b/BaseTools/Source/Python/Ecc/EccToolError.py > @@ -2,6 +2,7 @@ > # Standardized Error Handling infrastructures. > # > # Copyright (c) 2008 - 2018, Intel Corporation. All rights = reserved.
> +# Copyright (c) 2021, Arm Limited. All rights reserved.
> # SPDX-License-Identifier: BSD-2-Clause-Patent > # >=20 > @@ -161,7 +162,7 @@ gEccErrorMessage =3D { > ERROR_NAMING_CONVENTION_CHECK_ALL : "", > ERROR_NAMING_CONVENTION_CHECK_DEFINE_STATEMENT : "Only > capital letters are allowed to be used for #define declarations", > ERROR_NAMING_CONVENTION_CHECK_TYPEDEF_STATEMENT : "Only > capital letters are allowed to be used for typedef declarations", > - ERROR_NAMING_CONVENTION_CHECK_IFNDEF_STATEMENT : "The > #ifndef at the start of an include file should use both prefix and = postfix > underscore characters, '_'", > + ERROR_NAMING_CONVENTION_CHECK_IFNDEF_STATEMENT : "The > #ifndef at the start of an include file should have one postfix underscore, and > no prefix underscore character '_'", > ERROR_NAMING_CONVENTION_CHECK_PATH_NAME : """Path name > does not follow the rules: 1. First character should be upper case 2. = Must > contain lower case characters 3. No white space characters""", > ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME : > """Variable name does not follow the rules: 1. First character should = be upper > case 2. Must contain lower case characters 3. No white space = characters 4. > Global variable name must start with a 'g'""", > ERROR_NAMING_CONVENTION_CHECK_FUNCTION_NAME : > """Function name does not follow the rules: 1. First character should = be upper > case 2. Must contain lower case characters 3. No white space characters""", > -- > 2.17.1