]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Report error for incorrect hex value format
authorzhijufan <zhijux.fan@intel.com>
Tue, 11 Sep 2018 02:49:34 +0000 (10:49 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 12 Sep 2018 02:57:00 +0000 (10:57 +0800)
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>
BaseTools/Source/Python/Common/Misc.py

index 2cf9574326d5834488ac797b6a4a1be21cae1089..430bf6bcdabf07a1f45f55116c21edcd1863e849 100644 (file)
@@ -1414,7 +1414,10 @@ def ParseFieldValue (Value):
         Value = Value.strip().strip('"')\r
         return ParseDevPathValue(Value)\r
     if Value.lower().startswith('0x'):\r
-        Value = int(Value, 16)\r
+        try:\r
+            Value = int(Value, 16)\r
+        except:\r
+            raise BadExpression("invalid hex value: %s" % Value)\r
         if Value == 0:\r
             return 0, 1\r
         return Value, (Value.bit_length() + 7) / 8\r