From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 93A8021A00AC5 for ; Fri, 23 Jun 2017 00:49:42 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jun 2017 00:51:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,376,1493708400"; d="scan'208";a="117928452" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga005.fm.intel.com with ESMTP; 23 Jun 2017 00:51:08 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 23 Jun 2017 00:51:07 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.146]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.197]) with mapi id 14.03.0319.002; Fri, 23 Jun 2017 15:51:05 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Feng, YunhuaX" Thread-Topic: [Patch] BaseTools: Enhance DEC Defines section format check Thread-Index: AQHS6y8IVGiJkbnRIkKR18LB/FAc5KIyFI4A Date: Fri, 23 Jun 2017 07:51:05 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D74DE97@shsmsx102.ccr.corp.intel.com> References: <1498119023-8276-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1498119023-8276-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] BaseTools: Enhance DEC Defines section format check X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jun 2017 07:49:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable c:\r9tip\allpkg\edk2\mdemodulepkg\universal\pcd\pei\Service.h >-----Original Message----- >From: Zhu, Yonghong >Sent: Thursday, June 22, 2017 4:10 PM >To: edk2-devel@lists.01.org >Cc: Feng, YunhuaX ; Gao, Liming > >Subject: [Patch] BaseTools: Enhance DEC Defines section format check > >From: Yunhua Feng > >1. break if Dec Defines Section is missing >2. break if Dec have more than one Defines Section >3. break if Dec Defines Section have arch attribute >4. break if no section head, like as: >#[Defines] > DEC_SPECIFICATION =3D 0x00010005 > PACKAGE_NAME =3D Nt32Pkg > >Cc: Liming Gao >Cc: Yonghong Zhu >Contributed-under: TianoCore Contribution Agreement 1.0 >Signed-off-by: Yunhua Feng >--- > BaseTools/Source/Python/Workspace/MetaFileParser.py | 15 >+++++++++++++++ > 1 file changed, 15 insertions(+) > >diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py >b/BaseTools/Source/Python/Workspace/MetaFileParser.py >index d094403..6e236e6 100644 >--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py >+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py >@@ -1654,10 +1654,11 @@ class DecParser(MetaFileParser): > try: > Content =3D open(str(self.MetaFile), 'r').readlines() > except: > EdkLogger.error("Parser", FILE_READ_FAILURE, >ExtraData=3Dself.MetaFile) > >+ self._DefinesCount =3D 0 > for Index in range(0, len(Content)): > Line, Comment =3D CleanString2(Content[Index]) > self._CurrentLine =3D Line > self._LineIndex =3D Index > >@@ -1669,12 +1670,19 @@ class DecParser(MetaFileParser): > continue > > # section header > if Line[0] =3D=3D TAB_SECTION_START and Line[-1] =3D=3D TAB_S= ECTION_END: > self._SectionHeaderParser() >+ if self._SectionName =3D=3D TAB_DEC_DEFINES.upper(): >+ self._DefinesCount +=3D 1 > self._Comments =3D [] > continue >+ if self._SectionType =3D=3D MODEL_UNKNOWN: >+ EdkLogger.error("Parser", FORMAT_INVALID, >+ "" >+ "Not able to determine \"%s\" in which >section."%self._CurrentLine, >+ self.MetaFile, self._LineIndex + 1) > elif len(self._SectionType) =3D=3D 0: > self._Comments =3D [] > continue > > # section content >@@ -1718,10 +1726,14 @@ class DecParser(MetaFileParser): > LineNo, > - 1, > 0 > ) > self._Comments =3D [] >+ if self._DefinesCount > 1: >+ EdkLogger.error('Parser', FORMAT_INVALID, 'Multiple [Defines] >section is exist.', self.MetaFile ) >+ if self._DefinesCount =3D=3D 0: >+ EdkLogger.error('Parser', FORMAT_INVALID, 'No [Defines] secti= on >exist.',self.MetaFile) > self._Done() > > > ## Section header parser > # >@@ -1743,10 +1755,13 @@ class DecParser(MetaFileParser): > self.MetaFile, self._LineIndex + 1, self.= _CurrentLine) > ItemList =3D Item.split(TAB_SPLIT) > > # different types of PCD are permissible in one section > self._SectionName =3D ItemList[0].upper() >+ if self._SectionName =3D=3D TAB_DEC_DEFINES.upper() and (len(= ItemList) > >1 or len(Line.split(TAB_COMMA_SPLIT)) > 1): >+ EdkLogger.error("Parser", FORMAT_INVALID, "Defines sectio= n >format is invalid", >+ self.MetaFile, self._LineIndex + 1, self.= _CurrentLine) > if self._SectionName in self.DataType: > if self.DataType[self._SectionName] not in self._SectionT= ype: > self._SectionType.append(self.DataType[self._SectionN= ame]) > else: > EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is no= t a >valid section name" % Item, >-- >2.6.1.windows.1