From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.web08.10575.1611659268659419416 for ; Tue, 26 Jan 2021 03:07:49 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=Dveqv3SX; spf=pass (domain: nuviainc.com, ip: 209.85.128.47, mailfrom: leif@nuviainc.com) Received: by mail-wm1-f47.google.com with SMTP id m2so2095651wmm.1 for ; Tue, 26 Jan 2021 03:07:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=yruvTEUrjIjhBGjEPqFTAq/UpQrRAFQWSShf4QtbzRc=; b=Dveqv3SXdvF82aNO5utIxkeO9U2uZkwDbGD6DfYoyrFh358/mdysdwu7r9DarNlpL7 Wwy7bWCt0hxt1Iq+DCI/sTAuPZoHPtibRaNqsbYyO1U8jOiXxW15DDbt6wJ7l9EY7vbU /tkKkZNjQlvihKRWX080JVH9J7AJeEGkqaA0+6Lb9XgQufeEWY2AnV1eMkabWbCO0o66 cMQ8brgXTmRwrmZpK8Mm0ZxejCfrbgnz/TV+/BLI28Ogsk+SvFTaYwMiOEvzKrICQMwq X3twr2QRVdUkhVH6pVhffmJV7b8V+tNHLiry43dEjyWzSIp/ix+XXOkr1hA8Ebw0YGVv mUkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=yruvTEUrjIjhBGjEPqFTAq/UpQrRAFQWSShf4QtbzRc=; b=jFUzzVRvlx61ivT41WVtgsdvO0+zCvN3aRliJAa8TPj5Vbkt3aOUK6+KBi6XucrJHs sGpcq5AQcBapT11lt695E0M+txn4W0p+CYFzW3k/wwDsJrvu50Z1pWCiLqefZU4g3aAm rG/3a6/QwazZYmGYFnW9P5tCCg3wq+SLr5q3ax13oh8refGzttGhv1yi/dErWupLWBj0 FRPpkgyqoQVJLLaHpSPxQBATMKRVEufEQR9tqtxDGARxqkaJjoeZGvc8y6t7nkF+f2Or /IPcv2d5hW4VHOZDnTB5TmHYCeIUpGy7Jm3dXbDcbINmQjahczaA6Ot5qBE3mSwXVZ2Z Iw7A== X-Gm-Message-State: AOAM532y/Y+xnI/anB3Hn2bLbPDVixmAM60M6ULbW+66LqAtAEqlelPI BNONw7LFWnQWtNa61MhYJBOavdjSE6U2jkzQ74/gVU37RxVdedPo4iJwANfVWC8lz5lplbFbHB8 D5xZGMIh530Ao/ZeoZtd0NbeN+f+5Rgdp97Bwkyu0aooK1vOAHvMG/GBR0M6X3wU+FaZ2 X-Google-Smtp-Source: ABdhPJxwIETYQABj2p2JNqWn1DizzgOs/ktH1lCmC+2EN0MonJWEdWVsZYc4tROXkAR2Y7TJQS1cfg== X-Received: by 2002:a05:600c:22da:: with SMTP id 26mr4238375wmg.189.1611659266797; Tue, 26 Jan 2021 03:07:46 -0800 (PST) Return-Path: Received: from vanye (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id j2sm25044814wrh.78.2021.01.26.03.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 03:07:46 -0800 (PST) Date: Tue, 26 Jan 2021 11:07:44 +0000 From: "Leif Lindholm" To: devel@edk2.groups.io, gaoliming@byosoft.com.cn Cc: Pierre.Gondois@arm.com, bob.c.feng@intel.com, sami.mujawar@arm.com, 'Laszlo Ersek' , 'Michael D Kinney' , 'Andrew Fish' Subject: =?UTF-8?B?UmU6IFtlZGsyLWRldmVsXSDlm57lpI06IFtQQVRDSCB2MSAxLzFdIEJhc2VUb29sczogQWxpZ24gaW5jbHVkZSBndWFyZHMgcG9saWN5?= Message-ID: <20210126110744.GM1664@vanye> References: <20210125154525.18449-1-Pierre.Gondois@arm.com> <00f201d6f381$a8dd8970$fa989c50$@byosoft.com.cn> MIME-Version: 1.0 In-Reply-To: <00f201d6f381$a8dd8970$fa989c50$@byosoft.com.cn> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi Liming, If it was purely a question of style, I would agree that whatever is 70% used should be the norm. But this is not really an issue under our control. Macros starting with leading _ are reserved for toolchain use. Some toolchains, i.e. clang, have dedicated warnings for this. Whether we want to enforce this lazily (prevent new additions, change existing ones on rename) or with an all-out search-replace is a different question. Either way, this patch sounds like a useful change. Adding the check for the end of the string would also help improving code consistency. / Leif On Tue, Jan 26, 2021 at 09:22:06 +0800, gaoliming wrote: > 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. > > 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_. > > For this case, I would propose to update EDK II C Coding Standards > Specification to align the code. > > Thanks > Liming > > -----邮件原件----- > > 发件人: Pierre.Gondois@arm.com > > 发送时间: 2021年1月25日 23:45 > > 收件人: devel@edk2.groups.io; bob.c.feng@intel.com; > > gaoliming@byosoft.com.cn > > 抄送: sami.mujawar@arm.com > > 主题: [PATCH v1 1/1] BaseTools: Align include guards policy > > > > From: Pierre Gondois > > > > 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] > > > > 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. > > > > 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. > > > > [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 > > > > 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(-) > > > > 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 = EccGlobalData.gDb.TblFile.Exec(SqlCommand) > > for Record in RecordSet: > > Name = Record[1].replace('#ifndef', '').strip() > > - if Name[-1] != '_': > > + if Name[0] == '_' or Name[-1] != '_' or Name[-2] == '_': > > if not > > EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHE > > CK_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]) > > > > 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 > > # > > > > @@ -161,7 +162,7 @@ gEccErrorMessage = { > > 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 > > > > > > > >