public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Report error for incorrect hex value format
@ 2018-09-11  2:51 Yonghong Zhu
  2018-09-12  2:30 ` Zhu, Yonghong
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-09-11  2:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: zhijufan, Liming Gao

From: zhijufan <zhijux.fan@intel.com>

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>
---
 BaseTools/Source/Python/Common/Misc.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 2cf9574..430bf6b 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1412,11 +1412,14 @@ def ParseFieldValue (Value):
     if Value.startswith('DEVICE_PATH(') and Value.endswith(')'):
         Value = Value.replace("DEVICE_PATH(", '').rstrip(')')
         Value = Value.strip().strip('"')
         return ParseDevPathValue(Value)
     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:
             return 0, 1
         return Value, (Value.bit_length() + 7) / 8
     if Value[0].isdigit():
         Value = int(Value, 10)
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-12  2:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-11  2:51 [Patch] BaseTools: Report error for incorrect hex value format Yonghong Zhu
2018-09-12  2:30 ` Zhu, Yonghong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox