BaseTools: FdfParser - update to remove duplicate constant value

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>
This commit is contained in:
Carsey, Jaben 2018-04-28 06:32:15 +08:00 committed by Yonghong Zhu
parent ebafede928
commit bff747501b

View File

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