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.20; helo=mga02.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 8153F2117B555 for ; Tue, 23 Oct 2018 05:34:38 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2018 05:34:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,416,1534834800"; d="scan'208";a="84885621" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga006.jf.intel.com with ESMTP; 23 Oct 2018 05:34:38 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 23 Oct 2018 05:34:37 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 23 Oct 2018 05:34:37 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.84]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.102]) with mapi id 14.03.0415.000; Tue, 23 Oct 2018 20:34:35 +0800 From: "Zhu, Yonghong" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Chen, Hesheng" , "Zhu, Yonghong" Thread-Topic: [edk2] [PATCH V2] BaseTools/ECC: Add a checkpoint to check no usage for deprecated functions. Thread-Index: AQHUZoC6nhGRceMnaU27ccvTq1FjT6UszGuA Date: Tue, 23 Oct 2018 12:34:35 +0000 Message-ID: References: <1539825591-9140-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1539825591-9140-1-git-send-email-yonghong.zhu@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 V2] 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: Tue, 23 Oct 2018 12:34:38 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yong= hong Zhu Sent: Thursday, October 18, 2018 9:20 AM To: edk2-devel@lists.01.org Cc: Chen, Hesheng Subject: [edk2] [PATCH V2] BaseTools/ECC: Add a checkpoint to check no usag= e for deprecated functions. From: Hess Chen V2: change list to set 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/Pyt= hon/Ecc/EccToolError.py | 2 + BaseTools/Source/Python/Ecc/config.ini | 2 + 4 files changed, 67 insertions(+) diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python= /Ecc/Check.py index eb086362bd..d2192d10cb 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 EccGlobal= Data.gConfig.CheckAll =3D=3D '1': + EdkLogger.quiet("Checking function no deprecated one being=20 + used ...") + + DeprecatedFunctionSet =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 """ % (IdentifierTable,= MODEL_IDENTIFIER_FUNCTION_CALLING) + RecordSet =3D EccGlobalData.gDb.TblFile.Exec(SqlCommand) + for Record in RecordSet: + for Key in DeprecatedFunctionSet: + if Key =3D=3D Record[1]: + if not EccGlobalData.gException.IsException(ER= ROR_C_FUNCTION_LAYOUT_CHECK_NO_DEPRECATE, Key): + OtherMsg =3D 'The function [%s] is depreca= ted which should NOT be used' % Key + EccGlobalData.gDb.TblReport.Insert(ERROR_C= _FUNCTION_LAYOUT_CHECK_NO_DEPRECATE, + OtherMs= g=3DOtherMsg, + Belongs= ToTable=3DIdentifierTable, + =20 + BelongsToItem=3DRecord[0]) =20 def WalkTree(self): IgnoredPattern =3D c.GetIgnoredDirListPattern() diff --git a/BaseT= ools/Source/Python/Ecc/Configuration.py b/BaseTools/Source/Python/Ecc/Confi= guration.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":"CFunctionLayoutCheckFunctionP= rototype", + =20 + "CFunctionLayoutCheckNoDeprecated":"CFunctionLayoutCheckNoDeprecated", "CFunctionLayoutCheckNoInitOfVariable":"CFunctionLayoutCheckNoInitOfVa= riable", "CFunctionLayoutCheckNoStatic":"CFunctionLayoutCheckNoStatic", "CFunctionLayoutCheckOptionalFunctionalModifier":"CFunctionLayoutCheck= OptionalFunctionalModifier", @@ -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/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 500= 7 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 @@ g= EccErrorMessage =3D { ERROR_C_FUNCTION_LAYOUT_CHECK_DATA_DECLARATION : "The data declaration= s should be the first code in a module", ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VARIABLE : "There should be n= o initialization of a variable as part of its declaration", ERROR_C_FUNCTION_LAYOUT_CHECK_NO_STATIC : "There should be no use of S= TATIC 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 conten= ts should be guarded by a #ifndef statement.", diff --git a/BaseTools/Sourc= e/Python/Ecc/config.ini 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 CFunctionLay= outCheckNoInitOfVariable =3D 1 # Check whether no use of STATIC for functi= ons CFunctionLayoutCheckNoStatic =3D 1 +# Check whether no use of Deprecated functions=20 +CFunctionLayoutCheckNoDeprecated =3D 1 =20 # # Include Files Checking -- 2.14.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel