summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/AutoGen/GenC.py
diff options
context:
space:
mode:
authorYunhua Feng <yunhuax.feng@intel.com>2018-05-07 18:26:24 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-05-10 08:36:00 +0800
commit6b285ca3663d3c71cc68d01684a98f0d7537885e (patch)
tree3340c6ef5784e57b3f9e3567a489b8f5dea34694 /BaseTools/Source/Python/AutoGen/GenC.py
parent1dc287c3a3f1f090ef6b8ff80f7b3b3725071471 (diff)
downloadedk2-6b285ca3663d3c71cc68d01684a98f0d7537885e.tar.gz
edk2-6b285ca3663d3c71cc68d01684a98f0d7537885e.tar.bz2
edk2-6b285ca3663d3c71cc68d01684a98f0d7537885e.zip
BaseTools: Fix generating array's size is incorrect in AutoGen.c
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_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdName[2] = {0x41,0x42,0x43,0x44}; Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=950 Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/AutoGen/GenC.py')
-rw-r--r--BaseTools/Source/Python/AutoGen/GenC.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index d062588882..6192e86753 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1057,7 +1057,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
if not Value.endswith('U'):
Value += 'U'
if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES:
- if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '':
+ if not Pcd.MaxDatumSize:
EdkLogger.error("build", AUTOGEN_ERROR,
"Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName),
ExtraData="[%s]" % str(Info))
@@ -1065,11 +1065,13 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
ArraySize = int(Pcd.MaxDatumSize, 0)
if Value[0] == '{':
Type = '(VOID *)'
+ ValueSize = len(Value.split(','))
else:
if Value[0] == 'L':
Unicode = True
Value = Value.lstrip('L') #.strip('"')
Value = eval(Value) # translate escape character
+ ValueSize = len(Value) + 1
NewValue = '{'
for Index in range(0,len(Value)):
if Unicode:
@@ -1077,18 +1079,17 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
else:
NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ', '
if Unicode:
- ArraySize = 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, TokenCName),
- ExtraData="[%s]" % str(Info))
- else:
- ArraySize = Pcd.GetPcdSize()
- if Unicode:
- ArraySize = ArraySize / 2
+ ArraySize = ArraySize / 2
Value = 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, TokenCName),
+ ExtraData="[%s]" % str(Info))
+ else:
+ ArraySize = Pcd.GetPcdSize()
+ if Unicode:
+ ArraySize = ArraySize / 2
Array = '[%d]' % ArraySize
#
# skip casting for fixed at build since it breaks ARM assembly.