BaseTools/VfrCompile: report error for Integer overflow
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1415 When an integer constant specified in the .vfr file is too large for the varstore field it is being used with, the VFR compiler reports an overflow warning like this: Test.vfr(693): WARNING: Overflow: Value 1024 is too large to store in a UINT8 : String to UINT* Overflow Since Warning does not break the build process, and it is easy to miss it. This patch is to update the code to report error and break the build if meet this kind of issue. Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*++ @file
|
||||
Vfr Syntax
|
||||
|
||||
Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -5322,7 +5322,7 @@ EfiVfrParser::_STOU8 (
|
||||
}
|
||||
if((IsHex && ((Value/16) != PreviousValue)) || (!IsHex && ((Value/10) != PreviousValue))) {
|
||||
sprintf(ErrorMsg, "Overflow: Value %s is too large to store in a UINT8", OrigString);
|
||||
gCVfrErrorHandle.HandleWarning (VFR_WARNING_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);
|
||||
mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (VFR_RETURN_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5359,7 +5359,7 @@ EfiVfrParser::_STOU16 (
|
||||
}
|
||||
if((IsHex && ((Value/16) != PreviousValue)) || (!IsHex && ((Value/10) != PreviousValue))) {
|
||||
sprintf(ErrorMsg, "Overflow: Value %s is too large to store in a UINT16", OrigString);
|
||||
gCVfrErrorHandle.HandleWarning (VFR_WARNING_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);
|
||||
mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (VFR_RETURN_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5396,7 +5396,7 @@ EfiVfrParser::_STOU32 (
|
||||
}
|
||||
if((IsHex && ((Value/16) != PreviousValue)) || (!IsHex && ((Value/10) != PreviousValue ))) {
|
||||
sprintf(ErrorMsg, "Overflow: Value %s is too large to store in a UINT32", OrigString);
|
||||
gCVfrErrorHandle.HandleWarning (VFR_WARNING_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);
|
||||
mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (VFR_RETURN_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5432,7 +5432,7 @@ EfiVfrParser::_STOU64 (
|
||||
}
|
||||
if((IsHex && ((Value/16) != PreviousValue)) || ((!IsHex && (Value/10) != PreviousValue))) {
|
||||
sprintf(ErrorMsg, "Overflow: Value %s is too large to store in a UINT64", OrigString);
|
||||
gCVfrErrorHandle.HandleWarning (VFR_WARNING_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);
|
||||
mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (VFR_RETURN_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user