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 4E5CA203B9938 for ; Wed, 9 May 2018 17:34:47 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2018 17:34:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,383,1520924400"; d="scan'208";a="38142442" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga007.fm.intel.com with ESMTP; 09 May 2018 17:34:47 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 9 May 2018 17:34:47 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 9 May 2018 17:34:46 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.210]) by shsmsx102.ccr.corp.intel.com ([169.254.2.79]) with mapi id 14.03.0319.002; Thu, 10 May 2018 08:34:45 +0800 From: "Zhu, Yonghong" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Feng, YunhuaX" , "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [edk2] [Patch] BaseTools: Fix generating array's size is incorrect in AutoGen.c Thread-Index: AQHT52krPH4BSwi4GkiNnUq0HHjfpaQoHokQ Date: Thu, 10 May 2018 00:34:44 +0000 Message-ID: References: <1525851687-26732-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1525851687-26732-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: Fix generating array's size is incorrect in AutoGen.c X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2018 00:34:48 -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: Wednesday, May 09, 2018 3:41 PM To: edk2-devel@lists.01.org Cc: Feng, YunhuaX ; Gao, Liming Subject: [edk2] [Patch] BaseTools: Fix generating array's size is incorrect= in AutoGen.c From: Yunhua Feng case example: DSC: [PcdsFixedAtBuild] PcdToken.PcdName | "A" [Components] TestPkg/TestDriver.inf { PcdToken.PcdName | {0x41,0x42,0x43,0x44} } Generating the size of array is incorrect in AutoGen.c GLOBAL_REMOVE_IF_UN= REFERENCED const UINT8 _gPcd_FixedAtBuild_PcdName[2] =3D {0x41,0x42,0x43,0= x44}; Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=3D950 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/GenC.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/AutoGen/GenC.py index d062588..35ebd60 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1055,42 +1055,43 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, P= cd): "Too large PCD value for datum type [%= s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), ExtraData=3D"[%s]" % str(Info)) if not Value.endswith('U'): Value +=3D 'U' if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize =3D=3D '': + if not Pcd.MaxDatumSize: EdkLogger.error("build", AUTOGEN_ERROR, "Unknown [MaxDatumSize] of PCD [%s.%s]" % = (Pcd.TokenSpaceGuidCName, TokenCName), ExtraData=3D"[%s]" % str(Info)) =20 ArraySize =3D int(Pcd.MaxDatumSize, 0) if Value[0] =3D=3D '{': Type =3D '(VOID *)' + ValueSize =3D len(Value.split(',')) else: if Value[0] =3D=3D 'L': Unicode =3D True Value =3D Value.lstrip('L') #.strip('"') Value =3D eval(Value) # translate escape character + ValueSize =3D len(Value) + 1 NewValue =3D '{' for Index in range(0,len(Value)): if Unicode: NewValue =3D NewValue + str(ord(Value[Index]) % 0x= 10000) + ', ' else: NewValue =3D NewValue + str(ord(Value[Index]) % 0x= 100) + ', ' if Unicode: - ArraySize =3D ArraySize / 2; - - if ArraySize < (len(Value) + 1): - if Pcd.MaxSizeUserSet: - EdkLogger.error("build", AUTOGEN_ERROR, - "The maximum size of VOID* type PCD '%= s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, T= okenCName), - ExtraData=3D"[%s]" % str(Info)) - else: - ArraySize =3D Pcd.GetPcdSize() - if Unicode: - ArraySize =3D ArraySize / 2 + ArraySize =3D ArraySize / 2 Value =3D NewValue + '0 }' + if ArraySize < ValueSize: + if Pcd.MaxSizeUserSet: + EdkLogger.error("build", AUTOGEN_ERROR, + "The maximum size of VOID* type PCD '%s.%s= ' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Token= CName), + ExtraData=3D"[%s]" % str(Info)) + else: + ArraySize =3D Pcd.GetPcdSize() + if Unicode: + ArraySize =3D ArraySize / 2 Array =3D '[%d]' % ArraySize # # skip casting for fixed at build since it breaks ARM assembly. # Long term we need PCD macros that work in assembly # -- 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel