BaseTools: Report error for incorrect hex value format
The case is user use 0x1} as a hex value for Pcd, it directly cause tool report traceback info. This patch add more error info. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
@ -1414,7 +1414,10 @@ def ParseFieldValue (Value):
|
|||||||
Value = Value.strip().strip('"')
|
Value = Value.strip().strip('"')
|
||||||
return ParseDevPathValue(Value)
|
return ParseDevPathValue(Value)
|
||||||
if Value.lower().startswith('0x'):
|
if Value.lower().startswith('0x'):
|
||||||
Value = int(Value, 16)
|
try:
|
||||||
|
Value = int(Value, 16)
|
||||||
|
except:
|
||||||
|
raise BadExpression("invalid hex value: %s" % Value)
|
||||||
if Value == 0:
|
if Value == 0:
|
||||||
return 0, 1
|
return 0, 1
|
||||||
return Value, (Value.bit_length() + 7) / 8
|
return Value, (Value.bit_length() + 7) / 8
|
||||||
|
Reference in New Issue
Block a user