]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: FdfParser - update to remove duplicate constant value
authorCarsey, Jaben <jaben.carsey@intel.com>
Fri, 27 Apr 2018 22:32:15 +0000 (06:32 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Fri, 4 May 2018 05:02:57 +0000 (13:02 +0800)
PCD size by type is shared so this change both removes duplication
and makes the function work for all numeric PCD types.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/GenFds/FdfParser.py

index 49ed4041a287d687b51d8db2c5c565bf4937e311..223b453e7e8f302fcdef734bc8b2bd9d5f23578f 100644 (file)
@@ -1134,21 +1134,20 @@ class FdfParser:
 \r
     @staticmethod\r
     def __Verify(Name, Value, Scope):\r
-        if Scope in [TAB_UINT64, TAB_UINT8]:\r
-            ValueNumber = 0\r
-            try:\r
-                ValueNumber = int (Value, 0)\r
-            except:\r
-                EdkLogger.error("FdfParser", FORMAT_INVALID, "The value is not valid dec or hex number for %s." % Name)\r
-            if ValueNumber < 0:\r
-                EdkLogger.error("FdfParser", FORMAT_INVALID, "The value can't be set to negative value for %s." % Name)\r
-            if Scope == TAB_UINT64:\r
-                if ValueNumber >= 0x10000000000000000:\r
-                    EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value for %s." % Name)\r
-            if Scope == TAB_UINT8:\r
-                if ValueNumber >= 0x100:\r
-                    EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value for %s." % Name)\r
-            return True\r
+        # value verification only applies to numeric values.\r
+        if scope not in TAB_PCD_NUMERIC_TYPES:\r
+            return\r
+\r
+        ValueNumber = 0\r
+        try:\r
+            ValueNumber = int(Value, 0)\r
+        except:\r
+            EdkLogger.error("FdfParser", FORMAT_INVALID, "The value is not valid dec or hex number for %s." % Name)\r
+        if ValueNumber < 0:\r
+            EdkLogger.error("FdfParser", FORMAT_INVALID, "The value can't be set to negative value for %s." % Name)\r
+        if ValueNumber > MAX_VAL_TYPE[Scope]:\r
+            EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value for %s." % Name)\r
+        return True\r
 \r
     ## __UndoToken() method\r
     #\r