* [PATCH] BaseTools: Report error GUID format if incorrectly
@ 2018-02-05 3:42 Feng, YunhuaX
2018-02-06 1:11 ` Zhu, Yonghong
0 siblings, 1 reply; 2+ messages in thread
From: Feng, YunhuaX @ 2018-02-05 3:42 UTC (permalink / raw)
To: edk2-devel@lists.01.org; +Cc: Zhu, Yonghong, Gao, Liming
Flexible GUID format support like these:
1. { GUID("11E13869-1896-4A07-8B21-D8B23DD2A2B4") }
2. { GUID({ 0x11e13869, 0x1896, 0x4a07,{
0x8b, 0x21, 0xd8, 0xb2, 0x3d, 0xd2, 0xa2, 0xb4 } }) }
3. { GUID(gEfiBlockIoProtocolGuid) }
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>
---
BaseTools/Source/Python/Common/Misc.py | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index b8c2ce1ddc..5a0bcd9bf7 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1535,16 +1535,10 @@ def ParseFieldValue (Value):
if Value.startswith('GUID') and Value.endswith(')'):
Value = Value.split('(', 1)[1][:-1].strip()
if Value[0] == '{' and Value[-1] == '}':
- Value = Value[1:-1].strip()
- Value = Value.split('{', 1)
- Value = ['%02x' % int(Item, 16) for Item in (Value[0] + Value[1][:-1]).split(',')]
- if len(Value[0]) != 8:
- Value[0] = '%08X' % int(Value[0], 16)
- if len(Value[1]) != 4:
- Value[1] = '%04X' % int(Value[1], 16)
- if len(Value[2]) != 4:
- Value[2] = '%04X' % int(Value[2], 16)
- Value = '-'.join(Value[0:3]) + '-' + ''.join(Value[3:5]) + '-' + ''.join(Value[5:11])
+ TmpValue = GuidStructureStringToGuidString(Value)
+ if len(TmpValue) == 0:
+ raise BadExpression("Invalid GUID value string %s" % Value)
+ Value = TmpValue
if Value[0] == '"' and Value[-1] == '"':
Value = Value[1:-1]
try:
--
2.12.2.windows.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] BaseTools: Report error GUID format if incorrectly
2018-02-05 3:42 [PATCH] BaseTools: Report error GUID format if incorrectly Feng, YunhuaX
@ 2018-02-06 1:11 ` Zhu, Yonghong
0 siblings, 0 replies; 2+ messages in thread
From: Zhu, Yonghong @ 2018-02-06 1:11 UTC (permalink / raw)
To: Feng, YunhuaX, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Best Regards,
Zhu Yonghong
-----Original Message-----
From: Feng, YunhuaX
Sent: Monday, February 05, 2018 11:43 AM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [PATCH] BaseTools: Report error GUID format if incorrectly
Flexible GUID format support like these:
1. { GUID("11E13869-1896-4A07-8B21-D8B23DD2A2B4") } 2. { GUID({ 0x11e13869, 0x1896, 0x4a07,{
0x8b, 0x21, 0xd8, 0xb2, 0x3d, 0xd2, 0xa2, 0xb4 } }) } 3. { GUID(gEfiBlockIoProtocolGuid) }
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>
---
BaseTools/Source/Python/Common/Misc.py | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index b8c2ce1ddc..5a0bcd9bf7 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1535,16 +1535,10 @@ def ParseFieldValue (Value):
if Value.startswith('GUID') and Value.endswith(')'):
Value = Value.split('(', 1)[1][:-1].strip()
if Value[0] == '{' and Value[-1] == '}':
- Value = Value[1:-1].strip()
- Value = Value.split('{', 1)
- Value = ['%02x' % int(Item, 16) for Item in (Value[0] + Value[1][:-1]).split(',')]
- if len(Value[0]) != 8:
- Value[0] = '%08X' % int(Value[0], 16)
- if len(Value[1]) != 4:
- Value[1] = '%04X' % int(Value[1], 16)
- if len(Value[2]) != 4:
- Value[2] = '%04X' % int(Value[2], 16)
- Value = '-'.join(Value[0:3]) + '-' + ''.join(Value[3:5]) + '-' + ''.join(Value[5:11])
+ TmpValue = GuidStructureStringToGuidString(Value)
+ if len(TmpValue) == 0:
+ raise BadExpression("Invalid GUID value string %s" % Value)
+ Value = TmpValue
if Value[0] == '"' and Value[-1] == '"':
Value = Value[1:-1]
try:
--
2.12.2.windows.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-06 1:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-05 3:42 [PATCH] BaseTools: Report error GUID format if incorrectly Feng, YunhuaX
2018-02-06 1:11 ` Zhu, Yonghong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox