]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Report error when GUID format is incorrect
authorFeng, YunhuaX </o=Intel/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Feng, YunhuaX4e1>
Mon, 5 Feb 2018 03:42:33 +0000 (11:42 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 7 Feb 2018 01:29:08 +0000 (09:29 +0800)
Flexible GUID format of PCD value support following format, so tool should report
error when it is not correct.
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>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/Common/Misc.py

index 0365ac95314cd202f909bc219b4356cae04eb2ac..b13e35cd75421b414a2880c274e603f0d1f82ac1 100644 (file)
@@ -1535,16 +1535,10 @@ def ParseFieldValue (Value):
     if Value.startswith('GUID') and Value.endswith(')'):\r
         Value = Value.split('(', 1)[1][:-1].strip()\r
         if Value[0] == '{' and Value[-1] == '}':\r
-            Value = Value[1:-1].strip()\r
-            Value = Value.split('{', 1)\r
-            Value = ['%02x' % int(Item, 16) for Item in (Value[0] + Value[1][:-1]).split(',')]\r
-            if len(Value[0]) != 8:\r
-                Value[0] = '%08X' % int(Value[0], 16)\r
-            if len(Value[1]) != 4:\r
-                Value[1] = '%04X' % int(Value[1], 16)\r
-            if len(Value[2]) != 4:\r
-                Value[2] = '%04X' % int(Value[2], 16)\r
-            Value = '-'.join(Value[0:3]) + '-' + ''.join(Value[3:5]) + '-' + ''.join(Value[5:11])\r
+            TmpValue = GuidStructureStringToGuidString(Value)\r
+            if len(TmpValue) == 0:\r
+                raise BadExpression("Invalid GUID value string %s" % Value)\r
+            Value = TmpValue\r
         if Value[0] == '"' and Value[-1] == '"':\r
             Value = Value[1:-1]\r
         try:\r