From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 A56A821959CB2 for ; Thu, 30 Aug 2018 00:36:12 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Aug 2018 00:36:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,306,1531810800"; d="scan'208";a="67086123" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga008.fm.intel.com with ESMTP; 30 Aug 2018 00:36:07 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 30 Aug 2018 00:36:07 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 30 Aug 2018 00:36:06 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.143]) by shsmsx102.ccr.corp.intel.com ([169.254.2.226]) with mapi id 14.03.0319.002; Thu, 30 Aug 2018 15:36:04 +0800 From: "Gao, Liming" To: "Feng, Bob C" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] BaseTools: Fixed the PcdValue trailing zero issue. Thread-Index: AQHUPrkbSgmmn8hFdkagrzggEI4R+6TX6sBw Date: Thu, 30 Aug 2018 07:36:03 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E2EB4AC@SHSMSX104.ccr.corp.intel.com> References: <20180828102245.37636-1-bob.c.feng@intel.com> In-Reply-To: <20180828102245.37636-1-bob.c.feng@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: Fixed the PcdValue trailing zero issue. 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, 30 Aug 2018 07:36:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Feng, Bob C >Sent: Tuesday, August 28, 2018 6:23 PM >To: edk2-devel@lists.01.org >Cc: Feng, Bob C ; Gao, Liming >Subject: [Patch] BaseTools: Fixed the PcdValue trailing zero issue. > >1. Not append trailing zero for PcdValue >2. make sure the point to Variable Name in PCD >DataBase 2 bytes aligned. > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Bob Feng >Cc: Liming Gao >--- > BaseTools/Source/Python/AutoGen/GenPcdDb.py | 6 ++++++ > BaseTools/Source/Python/Common/StringUtils.py | 7 +------ > 2 files changed, 7 insertions(+), 6 deletions(-) > >diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py >b/BaseTools/Source/Python/AutoGen/GenPcdDb.py >index 2176bbefeb..5b260cd515 100644 >--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py >+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py >@@ -1182,10 +1182,16 @@ def CreatePcdDatabasePhaseSpecificAutoGen >(Platform, DynamicPcdList, Phase): > Pcd.InitString =3D 'INIT' > # Store all variable names of one HII PCD under different= SKU to >stringTable > # and calculate the VariableHeadStringIndex > > VariableNameStructure =3D StringToArray(Sku.VariableName) >+ >+ # Make pointer of VaraibleName(HII PCD) 2 bytes aligned >+ VariableNameStructureBytes =3D >VariableNameStructure.lstrip("{").rstrip("}").split(",") >+ if len(VariableNameStructureBytes) % 2: >+ VariableNameStructure =3D "{%s,0x00}" % >",".join(VariableNameStructureBytes) >+ > if VariableNameStructure not in Dict['STRING_TABLE_VALUE'= ]: > Dict['STRING_TABLE_CNAME'].append(CName) > Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid) > if StringTableIndex =3D=3D 0: > Dict['STRING_TABLE_INDEX'].append('') >diff --git a/BaseTools/Source/Python/Common/StringUtils.py >b/BaseTools/Source/Python/Common/StringUtils.py >index da2949dbad..d5afde7a95 100644 >--- a/BaseTools/Source/Python/Common/StringUtils.py >+++ b/BaseTools/Source/Python/Common/StringUtils.py >@@ -833,16 +833,11 @@ def StringToArray(String): > if StringLen % 2: > return "{%s,0x00}" % ",".join("0x%02x" % ord(C) for C in = String[1:-1]) > else: > return "{%s,0x00,0x00}" % ",".join("0x%02x" % ord(C) for = C in >String[1:-1]) > elif String.startswith('{'): >- StringLen =3D len(String.split(",")) >- if StringLen % 2: >- return "{%s,0x00}" % ",".join(C.strip() for C in String[1:-1]= .split(',')) >- else: >- return "{%s}" % ",".join(C.strip() for C in String[1:-1].spli= t(',')) >- >+ return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(',= ')) > else: > if len(String.split()) % 2: > return '{%s,0}' % ','.join(String.split()) > else: > return '{%s,0,0}' % ','.join(String.split()) >-- >2.16.2.windows.1