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.24; helo=mga09.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 7178C21167455 for ; Wed, 17 Oct 2018 08:48:42 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2018 08:48:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,393,1534834800"; d="scan'208";a="242087598" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga004.jf.intel.com with ESMTP; 17 Oct 2018 08:48:41 -0700 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 17 Oct 2018 08:48:41 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.16]) by FMSMSX125.amr.corp.intel.com ([169.254.2.176]) with mapi id 14.03.0319.002; Wed, 17 Oct 2018 08:48:41 -0700 From: "Carsey, Jaben" To: "Zhu, Yonghong" CC: "edk2-devel@lists.01.org" , "Chen, Hesheng" Thread-Topic: [edk2] [PATCH] BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions. Thread-Index: AQHUZcCwYiEBwygr1Ey6Naa4/vXGa6Ujlj8W Date: Wed, 17 Oct 2018 15:48:41 +0000 Message-ID: <22AD787D-7975-4AC5-8F27-C8209F0EC766@intel.com> References: <1539743126-6736-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1539743126-6736-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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: Wed, 17 Oct 2018 15:48:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Propose to use a set not a list when the data is unordered and unique names= 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 ++ > 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 b/BaseTools/Source/Pyt= hon/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()=20 > + > + # 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 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, > + Belo= ngsToItem=3DRecord[0]) >=20 > def WalkTree(self): > IgnoredPattern =3D c.GetIgnoredDirListPattern() > diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/So= urce/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= ", > "CFunctionLayoutCheckFunctionPrototype":"CFunctionLayoutCheckFunctio= nPrototype", > + "CFunctionLayoutCheckNoDeprecated":"CFunctionLayoutCheckNoDeprecate= d", > "CFunctionLayoutCheckNoInitOfVariable":"CFunctionLayoutCheckNoInitOf= Variable", > "CFunctionLayoutCheckNoStatic":"CFunctionLayoutCheckNoStatic", > "CFunctionLayoutCheckOptionalFunctionalModifier":"CFunctionLayoutChe= ckOptionalFunctionalModifier", > @@ -242,6 +243,8 @@ class 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 b/BaseTools/Sou= rce/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 = 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 @@ 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 of= STATIC for functions", > + ERROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE : "The deprecated functi= on should NOT be used", >=20 > ERROR_INCLUDE_FILE_CHECK_ALL : "", > ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1 : "All include file cont= ents should be guarded by a #ifndef statement.", > diff --git a/BaseTools/Source/Python/Ecc/config.ini b/BaseTools/Source/P= ython/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 > CFunctionLayoutCheckNoInitOfVariable =3D 1 > # Check whether no use of STATIC for functions > CFunctionLayoutCheckNoStatic =3D 1 > +# Check whether no use of Deprecated functions > +CFunctionLayoutCheckNoDeprecated =3D 1 >=20 > # > # Include Files Checking > --=20 > 2.14.2.windows.2 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel