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....@intel.com>
Cc: Yonghong Zhu <yonghong....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.car...@intel.com>
---
 BaseTools/Source/Python/GenFds/FdfParser.py | 29 ++++++++++----------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 25755a9778f2..80ff3ece43b4 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1134,21 +1134,20 @@ class FdfParser:
 
     @staticmethod
     def __Verify(Name, Value, Scope):
-        if Scope in [TAB_UINT64, TAB_UINT8]:
-            ValueNumber = 0
-            try:
-                ValueNumber = int (Value, 0)
-            except:
-                EdkLogger.error("FdfParser", FORMAT_INVALID, "The value is not 
valid dec or hex number for %s." % Name)
-            if ValueNumber < 0:
-                EdkLogger.error("FdfParser", FORMAT_INVALID, "The value can't 
be set to negative value for %s." % Name)
-            if Scope == TAB_UINT64:
-                if ValueNumber >= 0x10000000000000000:
-                    EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large 
value for %s." % Name)
-            if Scope == TAB_UINT8:
-                if ValueNumber >= 0x100:
-                    EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large 
value for %s." % Name)
-            return True
+        # value verification only applies to numeric values.
+        if scope not in TAB_PCD_NUMERIC_TYPES:
+            return
+
+        ValueNumber = 0
+        try:
+            ValueNumber = int(Value, 0)
+        except:
+            EdkLogger.error("FdfParser", FORMAT_INVALID, "The value is not 
valid dec or hex number for %s." % Name)
+        if ValueNumber < 0:
+            EdkLogger.error("FdfParser", FORMAT_INVALID, "The value can't be 
set to negative value for %s." % Name)
+        if ValueNumber > MAX_VAL_TYPE[Scope]:
+            EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value for 
%s." % Name)
+        return True
 
     ## __UndoToken() method
     #
-- 
2.16.2.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to