From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=hesheng.chen@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A92B12117AE4D for ; Wed, 17 Oct 2018 17:44:35 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2018 17:44:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,393,1534834800"; d="scan'208";a="272235375" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga005.fm.intel.com with ESMTP; 17 Oct 2018 17:44:34 -0700 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 17 Oct 2018 17:44:34 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 17 Oct 2018 17:44:34 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.48]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.245]) with mapi id 14.03.0319.002; Thu, 18 Oct 2018 08:44:31 +0800 From: "Chen, Hesheng" To: "Carsey, Jaben" , "Zhu, Yonghong" CC: "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH] BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions. Thread-Index: AQHUZcCxKiAQ6M/O1EavTV7CjGWgk6UjECOAgAEbkmA= Date: Thu, 18 Oct 2018 00:44:31 +0000 Message-ID: <3A06C110936C5348AEB96EBC072758C34D1B9AA3@SHSMSX104.ccr.corp.intel.com> References: <1539743126-6736-1-git-send-email-yonghong.zhu@intel.com> <22AD787D-7975-4AC5-8F27-C8209F0EC766@intel.com> In-Reply-To: <22AD787D-7975-4AC5-8F27-C8209F0EC766@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Oct 2018 00:44:35 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Good suggestion, will update the patch. Chen, Hess Intel China Software Center Tel: +86-21-6116-6740 Email: hesheng.chen@intel.com -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Car= sey, Jaben Sent: Wednesday, October 17, 2018 11:49 PM To: Zhu, Yonghong Cc: edk2-devel@lists.01.org; Chen, Hesheng Subject: Re: [edk2] [PATCH] BaseTools/ECC: Add a checkpoint to check no us= age for deprecated functions. Propose to use a set not a list when the data is unordered and unique name= s of functions. With that: reviewed-by:Jaben.carsey > On Oct 16, 2018, at 7:25 PM, Yonghong Zhu wrote= : >=20 > From: Hess Chen >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hess Chen > --- > BaseTools/Source/Python/Ecc/Check.py | 60 ++++++++++++++++++++++= ++++++ > BaseTools/Source/Python/Ecc/Configuration.py | 3 ++=20 > BaseTools/Source/Python/Ecc/EccToolError.py | 2 + > BaseTools/Source/Python/Ecc/config.ini | 2 + > 4 files changed, 67 insertions(+) >=20 > diff --git a/BaseTools/Source/Python/Ecc/Check.py=20 > b/BaseTools/Source/Python/Ecc/Check.py > index eb086362bd..3baf81fa44 100644 > --- a/BaseTools/Source/Python/Ecc/Check.py > +++ b/BaseTools/Source/Python/Ecc/Check.py > @@ -270,6 +270,66 @@ class Check(object): > self.FunctionLayoutCheckPrototype() > self.FunctionLayoutCheckBody() > self.FunctionLayoutCheckLocalVariable() > + self.FunctionLayoutCheckDeprecated() > + > + # To check if the deprecated functions are used > + def FunctionLayoutCheckDeprecated(self): > + if EccGlobalData.gConfig.CFunctionLayoutCheckNoDeprecated =3D= =3D '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll =3D=3D '1' or Ecc= GlobalData.gConfig.CheckAll =3D=3D '1': > + EdkLogger.quiet("Checking function no deprecated one=20 > + being used ...") > + > + DeprecatedFunctionList =3D ['UnicodeValueToString', > + 'AsciiValueToString', > + 'StrCpy', > + 'StrnCpy', > + 'StrCat', > + 'StrnCat', > + 'UnicodeStrToAsciiStr', > + 'AsciiStrCpy', > + 'AsciiStrnCpy', > + 'AsciiStrCat', > + 'AsciiStrnCat', > + 'AsciiStrToUnicodeStr', > + 'PcdSet8', > + 'PcdSet16', > + 'PcdSet32', > + 'PcdSet64', > + 'PcdSetPtr', > + 'PcdSetBool', > + 'PcdSetEx8', > + 'PcdSetEx16', > + 'PcdSetEx32', > + 'PcdSetEx64', > + 'PcdSetExPtr', > + 'PcdSetExBool', > + 'LibPcdSet8', > + 'LibPcdSet16', > + 'LibPcdSet32', > + 'LibPcdSet64', > + 'LibPcdSetPtr', > + 'LibPcdSetBool', > + 'LibPcdSetEx8', > + 'LibPcdSetEx16', > + 'LibPcdSetEx32', > + 'LibPcdSetEx64', > + 'LibPcdSetExPtr', > + 'LibPcdSetExBool', > + 'GetVariable', > + 'GetEfiGlobalVariable', > + ] > + > + for IdentifierTable in EccGlobalData.gIdentifierTableList: > + SqlCommand =3D """select ID, Name, BelongsToFile from %= s > + where Model =3D %s """ % (IdentifierTab= le, MODEL_IDENTIFIER_FUNCTION_CALLING) > + RecordSet =3D EccGlobalData.gDb.TblFile.Exec(SqlCommand= ) > + for Record in RecordSet: > + for Key in DeprecatedFunctionList: > + if Key =3D=3D Record[1]: > + if not EccGlobalData.gException.IsException= (ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE, Key): > + OtherMsg =3D 'The function [%s] is depr= ecated which should NOT be used' % Key > + EccGlobalData.gDb.TblReport.Insert(ERRO= R_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE, > + Othe= rMsg=3DOtherMsg, > + Belo= ngsToTable=3DIdentifierTable, > + =20 > + BelongsToItem=3DRecord[0]) >=20 > def WalkTree(self): > IgnoredPattern =3D c.GetIgnoredDirListPattern() diff --git=20 > a/BaseTools/Source/Python/Ecc/Configuration.py=20 > b/BaseTools/Source/Python/Ecc/Configuration.py > index c19a3990c7..8f6886169c 100644 > --- a/BaseTools/Source/Python/Ecc/Configuration.py > +++ b/BaseTools/Source/Python/Ecc/Configuration.py > @@ -34,6 +34,7 @@ _ConfigFileToInternalTranslation =3D { > "CFunctionLayoutCheckFunctionBody":"CFunctionLayoutCheckFunctionBody= ", > "CFunctionLayoutCheckFunctionName":"CFunctionLayoutCheckFunctionName= ", > =20 > "CFunctionLayoutCheckFunctionPrototype":"CFunctionLayoutCheckFunctionP > rototype", > + > + "CFunctionLayoutCheckNoDeprecated":"CFunctionLayoutCheckNoDeprecated > + ", > "CFunctionLayoutCheckNoInitOfVariable":"CFunctionLayoutCheckNoInitOf= Variable", > "CFunctionLayoutCheckNoStatic":"CFunctionLayoutCheckNoStatic", > =20 > "CFunctionLayoutCheckOptionalFunctionalModifier":"CFunctionLayoutCheck > OptionalFunctionalModifier", @@ -242,6 +243,8 @@ class=20 > Configuration(object): > self.CFunctionLayoutCheckNoInitOfVariable =3D 1 > # Check whether no use of STATIC for functions > self.CFunctionLayoutCheckNoStatic =3D 1 > + # Check whether no use of Deprecated functions > + self.CFunctionLayoutCheckNoDeprecated =3D 1 >=20 > ## Include Files Checking > self.IncludeFileCheckAll =3D 0 > diff --git a/BaseTools/Source/Python/Ecc/EccToolError.py=20 > b/BaseTools/Source/Python/Ecc/EccToolError.py > index e327a7888d..7663e90d7e 100644 > --- a/BaseTools/Source/Python/Ecc/EccToolError.py > +++ b/BaseTools/Source/Python/Ecc/EccToolError.py > @@ -47,6 +47,7 @@ ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VARIABLE =3D= =20 > 5007 ERROR_C_FUNCTION_LAYOUT_CHECK_NO_STATIC =3D 5008 > ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_2 =3D 5009 > ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_3 =3D 5010 > +ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE =3D 5011 >=20 > ERROR_INCLUDE_FILE_CHECK_ALL =3D 6000 > ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1 =3D 6001 @@ -146,6 +147,7 @@= = =20 > gEccErrorMessage =3D { > ERROR_C_FUNCTION_LAYOUT_CHECK_DATA_DECLARATION : "The data declarati= ons should be the first code in a module", > ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VARIABLE : "There should be= no initialization of a variable as part of its declaration", > ERROR_C_FUNCTION_LAYOUT_CHECK_NO_STATIC : "There should be no use=20 > of STATIC for functions", > + ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE : "The deprecated=20 > + function should NOT be used", >=20 > ERROR_INCLUDE_FILE_CHECK_ALL : "", > ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1 : "All include file=20 > contents should be guarded by a #ifndef statement.", diff --git=20 > a/BaseTools/Source/Python/Ecc/config.ini=20 > b/BaseTools/Source/Python/Ecc/config.ini > index 00c98c6232..663ae293bd 100644 > --- a/BaseTools/Source/Python/Ecc/config.ini > +++ b/BaseTools/Source/Python/Ecc/config.ini > @@ -134,6 +134,8 @@ CFunctionLayoutCheckDataDeclaration =3D 1=20 > CFunctionLayoutCheckNoInitOfVariable =3D 1 # Check whether no use of=20 > STATIC for functions CFunctionLayoutCheckNoStatic =3D 1 > +# Check whether no use of Deprecated functions=20 > +CFunctionLayoutCheckNoDeprecated =3D 1 >=20 > # > # Include Files Checking > -- > 2.14.2.windows.2 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel