* Re: [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds DefaultValueError [not found] <17BEB716C0DD8A75.2828@groups.io> @ 2024-03-21 7:54 ` Yuting Yang 2024-03-28 7:28 ` Zhang, Zifeng 0 siblings, 1 reply; 3+ messages in thread From: Yuting Yang @ 2024-03-21 7:54 UTC (permalink / raw) To: devel@edk2.groups.io, gaoliming Cc: Chen, Christine, Zhang, Zifeng, Feng, Bob C, He, Haiyang Hi liming, Gentle reminder, we have removed the whitespace. Please help review the patch~ Thanks, Yuting -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yuting Yang Sent: Thursday, March 21, 2024 3:30 PM To: devel@edk2.groups.io Cc: Rebecca Cran <rebecca@bsdio.com>; Liming Gao <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>; Chen, Christine <yuwei.chen@intel.com>; Zhang, Zifeng <zifeng.zhang@intel.com> Subject: [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds DefaultValueError Add --catch_default option Raise a DefaultValueError when encountering VFR default definitions to help remove default variables. Signed-off-by: Yuting Yang <yuting2.yang@intel.com> Cc: Rebecca Cran <rebecca@bsdio.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Bob Feng <bob.c.feng@intel.com> Cc: Christine Chen <yuwei.chen@intel.com> Cc: Zifeng Zhang <zifeng.zhang@intel.com> --- BaseTools/Source/C/VfrCompile/VfrCompiler.cpp | 8 ++++---- BaseTools/Source/C/VfrCompile/VfrCompiler.h | 1 + BaseTools/Source/C/VfrCompile/VfrError.cpp | 3 ++- BaseTools/Source/C/VfrCompile/VfrError.h | 3 ++- BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 1 + BaseTools/Source/C/VfrCompile/VfrSyntax.g | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 6 files changed, 60 insertions(+), 14 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp index 5f4d262d85..4031af6e39 100644 --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp @@ -78,6 +78,7 @@ CVfrCompiler::OptionInitialization ( mOptions.WarningAsError = FALSE; mOptions.AutoDefault = FALSE; mOptions.CheckDefault = FALSE;+ mOptions.IsCatchDefaultEnable = FALSE; memset (&mOptions.OverrideClassGuid, 0, sizeof (EFI_GUID)); if (Argc == 1) {@@ -95,6 +96,8 @@ CVfrCompiler::OptionInitialization ( Version (); SET_RUN_STATUS (STATUS_DEAD); return;+ } else if (stricmp(Argv[Index], "--catch_default") == 0){+ mOptions.IsCatchDefaultEnable = TRUE; } else if (stricmp(Argv[Index], "-l") == 0) { mOptions.CreateRecordListFile = TRUE; gCIfrRecordInfoDB.TurnOn ();@@ -179,7 +182,6 @@ CVfrCompiler::OptionInitialization ( goto Fail; } strcpy (mOptions.VfrFileName, Argv[Index]);- if (mOptions.OutputDirectory == NULL) { mOptions.OutputDirectory = (CHAR8 *) malloc (1); if (mOptions.OutputDirectory == NULL) {@@ -679,7 +681,7 @@ CVfrCompiler::Compile ( DebugError (NULL, 0, 0001, "Error opening the input file", "%s", InFileName); goto Fail; }-+ InputInfo.IsCatchDefaultEnable = mOptions.IsCatchDefaultEnable; if (mOptions.HasOverrideClassGuid) { InputInfo.OverrideClassGuid = &mOptions.OverrideClassGuid; } else {@@ -937,5 +939,3 @@ main ( return GetUtilityStatus (); }--diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.h b/BaseTools/Source/C/VfrCompile/VfrCompiler.h index b6e207d2ce..974f37c4eb 100644 --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.h +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.h @@ -52,6 +52,7 @@ typedef struct { BOOLEAN WarningAsError; BOOLEAN AutoDefault; BOOLEAN CheckDefault;+ BOOLEAN IsCatchDefaultEnable; } OPTIONS; typedef enum {diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp b/BaseTools/Source/C/VfrCompile/VfrError.cpp index 65bb8e34fd..8a706f929b 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp @@ -49,7 +49,8 @@ static SVFR_WARNING_HANDLE VFR_WARNING_HANDLE_TABLE [] = { { VFR_WARNING_DEFAULT_VALUE_REDEFINED, ": default value re-defined with different value"}, { VFR_WARNING_ACTION_WITH_TEXT_TWO, ": Action opcode should not have TextTwo part"}, { VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE, ": Not recommend to use obsoleted framework opcode"},- { VFR_WARNING_CODEUNDEFINED, ": undefined Warning Code" }+ { VFR_WARNING_CODEUNDEFINED, ": undefined Warning Code" },+ { VFR_WARNING_UNSUPPORTED, ": pls remove the default values if necessary" } }; CVfrErrorHandle::CVfrErrorHandle (diff --git a/BaseTools/Source/C/VfrCompile/VfrError.h b/BaseTools/Source/C/VfrCompile/VfrError.h index 7d16bd5f74..1b4bc173d2 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.h +++ b/BaseTools/Source/C/VfrCompile/VfrError.h @@ -47,7 +47,8 @@ typedef enum { VFR_WARNING_DEFAULT_VALUE_REDEFINED = 0, VFR_WARNING_ACTION_WITH_TEXT_TWO, VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE,- VFR_WARNING_CODEUNDEFINED+ VFR_WARNING_CODEUNDEFINED,+ VFR_WARNING_UNSUPPORTED } EFI_VFR_WARNING_CODE; typedef struct _SVFR_ERROR_HANDLE {diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h index 9ef6f07787..d8fada3bcb 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h @@ -96,6 +96,7 @@ struct SBufferNode { typedef struct { EFI_GUID *OverrideClassGuid;+ BOOLEAN IsCatchDefaultEnable; } INPUT_INFO_TO_SYNTAX; class CFormPkg {diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index 55fd067f8a..d7376122d8 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -50,6 +50,7 @@ VfrParserStart ( { ParserBlackBox<CVfrDLGLexer, EfiVfrParser, ANTLRToken> VfrParser(File); VfrParser.parser()->SetOverrideClassGuid (InputInfo->OverrideClassGuid);+ VfrParser.parser()->SetIsCatchDefaultEnable(InputInfo->IsCatchDefaultEnable); return VfrParser.parser()->vfrProgram(); } >>@@ -975,7 +976,15 @@ vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize, vfrStatementDefaultStore : << UINT16 DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; >>- D:DefaultStore N:StringIdentifier ","+ D:DefaultStore N:StringIdentifier "," <<+ if (mIsCatchDefaultEnable) {+ gCVfrErrorHandle.HandleWarning (+ VFR_WARNING_UNSUPPORTED,+ D->getLine(),+ D->getText()+ );+ }+ >> Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" { "," Attribute "=" A:Number << DefaultId = _STOU16(A->getText(), A->getLine()); >>@@ -1775,7 +1784,11 @@ vfrStatementDefault : CIfrNumeric *NumericQst = NULL; >>- D:Default + D:Default <<+ if (mIsCatchDefaultEnable) {+ DefaultValueError(VFR_RETURN_UNSUPPORTED, D->getLine());+ }+ >> ( ( "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE(), *Val, ArrayType] "," @@ -1970,11 +1983,15 @@ vfrStatementInvalid : ; flagsField :- Number - | InteractiveFlag - | ManufacturingFlag - | DefaultFlag - | ResetRequiredFlag + Number+ | InteractiveFlag+ | ManufacturingFlag+ | D:DefaultFlag <<+ if (mIsCatchDefaultEnable) {+ DefaultValueError(VFR_RETURN_UNSUPPORTED, D->getLine());+ }+ >>+ | ResetRequiredFlag | ReconnectRequiredFlag | N:NVAccessFlag << gCVfrErrorHandle.HandleWarning (@@ -3790,7 +3807,12 @@ oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] : | RestStyleFlag << $HFlags |= 0x20; >> | ReconnectRequiredFlag << $HFlags |= 0x40; >> | ManufacturingFlag << $LFlags |= 0x20; >>- | DefaultFlag << $LFlags |= 0x10; >>+ | D:DefaultFlag <<+ $LFlags |= 0x10;+ if (mIsCatchDefaultEnable) {+ DefaultValueError(VFR_RETURN_UNSUPPORTED, D->getLine());+ }+ >> | A:NVAccessFlag << gCVfrErrorHandle.HandleWarning ( VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE,@@ -4837,6 +4859,7 @@ spanFlags [UINT8 & Flags] : class EfiVfrParser { << private:+ BOOLEAN mIsCatchDefaultEnable; UINT8 mParserStatus; BOOLEAN mConstantOnlyInExpression; @@ -4880,6 +4903,7 @@ public: VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr); VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32); VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN CONST CHAR8 *);+ VOID DefaultValueError (IN EFI_VFR_RETURN_CODE, IN UINT32); VOID syn (ANTLRAbstractToken *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32); @@ -4909,6 +4933,7 @@ public: VOID IdEqIdDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_COMPARE_TYPE); VOID IdEqListDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN UINT16 *); VOID SetOverrideClassGuid (IN EFI_GUID *);+ VOID SetIsCatchDefaultEnable (BOOLEAN IsCatchDefaultEnable); >> } @@ -5086,6 +5111,17 @@ EfiVfrParser::_PCATCH ( mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, (CHAR8 *) ErrorMsg); } +VOID+EfiVfrParser::DefaultValueError (+ IN EFI_VFR_RETURN_CODE ReturnCode,+ IN UINT32 LineNum+ )+{+ CHAR8 ErrorMsg[100];+ sprintf(ErrorMsg, "please remove the default value / defaultstore in line %d", LineNum);+ mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, ErrorMsg);+}+ VOID EfiVfrParser::syn ( ANTLRAbstractToken *Tok,@@ -5688,6 +5724,12 @@ EfiVfrParser::SetOverrideClassGuid (IN EFI_GUID *OverrideClassGuid) mOverrideClassGuid = OverrideClassGuid; } +VOID+EfiVfrParser::SetIsCatchDefaultEnable (BOOLEAN IsCatchDefaultEnable)+{+ mIsCatchDefaultEnable = IsCatchDefaultEnable;+}+ VOID EfiVfrParser::CheckDuplicateDefaultValue ( IN EFI_DEFAULT_ID DefaultId,-- 2.39.1.windows.1 -=-=-=-=-=-= Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116948): https://edk2.groups.io/g/devel/message/116948 Mute This Topic: https://groups.io/mt/105061128/7976666 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [yuting2.yang@intel.com] -=-=-=-=-=-= -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116949): https://edk2.groups.io/g/devel/message/116949 Mute This Topic: https://groups.io/mt/105061128/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds DefaultValueError 2024-03-21 7:54 ` [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds DefaultValueError Yuting Yang @ 2024-03-28 7:28 ` Zhang, Zifeng 2024-04-02 1:09 ` 回复: " gaoliming via groups.io 0 siblings, 1 reply; 3+ messages in thread From: Zhang, Zifeng @ 2024-03-28 7:28 UTC (permalink / raw) To: Yang, Yuting2, devel@edk2.groups.io, gaoliming Cc: Chen, Christine, Feng, Bob C, He, Haiyang Thanks Yuting for patch update! Hi @gaoliming, Would you like to review the V4 patch? Hope to merge it asap to avoid blocking feature complete. Best Regards, Zifeng -----Original Message----- From: Yang, Yuting2 <yuting2.yang@intel.com> Sent: Thursday, March 21, 2024 3:54 PM To: devel@edk2.groups.io; gaoliming <gaoliming@byosoft.com.cn> Cc: Chen, Christine <yuwei.chen@intel.com>; Zhang, Zifeng <zifeng.zhang@intel.com>; Feng, Bob C <bob.c.feng@intel.com>; He, Haiyang <haiyang.he@intel.com> Subject: RE: [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds DefaultValueError Hi liming, Gentle reminder, we have removed the whitespace. Please help review the patch~ Thanks, Yuting -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yuting Yang Sent: Thursday, March 21, 2024 3:30 PM To: devel@edk2.groups.io Cc: Rebecca Cran <rebecca@bsdio.com>; Liming Gao <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>; Chen, Christine <yuwei.chen@intel.com>; Zhang, Zifeng <zifeng.zhang@intel.com> Subject: [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds DefaultValueError Add --catch_default option Raise a DefaultValueError when encountering VFR default definitions to help remove default variables. Signed-off-by: Yuting Yang <yuting2.yang@intel.com> Cc: Rebecca Cran <rebecca@bsdio.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Bob Feng <bob.c.feng@intel.com> Cc: Christine Chen <yuwei.chen@intel.com> Cc: Zifeng Zhang <zifeng.zhang@intel.com> --- BaseTools/Source/C/VfrCompile/VfrCompiler.cpp | 8 ++++---- BaseTools/Source/C/VfrCompile/VfrCompiler.h | 1 + BaseTools/Source/C/VfrCompile/VfrError.cpp | 3 ++- BaseTools/Source/C/VfrCompile/VfrError.h | 3 ++- BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 1 + BaseTools/Source/C/VfrCompile/VfrSyntax.g | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 6 files changed, 60 insertions(+), 14 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp index 5f4d262d85..4031af6e39 100644 --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp @@ -78,6 +78,7 @@ CVfrCompiler::OptionInitialization ( mOptions.WarningAsError = FALSE; mOptions.AutoDefault = FALSE; mOptions.CheckDefault = FALSE;+ mOptions.IsCatchDefaultEnable = FALSE; memset (&mOptions.OverrideClassGuid, 0, sizeof (EFI_GUID)); if (Argc == 1) {@@ -95,6 +96,8 @@ CVfrCompiler::OptionInitialization ( Version (); SET_RUN_STATUS (STATUS_DEAD); return;+ } else if (stricmp(Argv[Index], "--catch_default") == 0){+ mOptions.IsCatchDefaultEnable = TRUE; } else if (stricmp(Argv[Index], "-l") == 0) { mOptions.CreateRecordListFile = TRUE; gCIfrRecordInfoDB.TurnOn ();@@ -179,7 +182,6 @@ CVfrCompiler::OptionInitialization ( goto Fail; } strcpy (mOptions.VfrFileName, Argv[Index]);- if (mOptions.OutputDirectory == NULL) { mOptions.OutputDirectory = (CHAR8 *) malloc (1); if (mOptions.OutputDirectory == NULL) {@@ -679,7 +681,7 @@ CVfrCompiler::Compile ( DebugError (NULL, 0, 0001, "Error opening the input file", "%s", InFileName); goto Fail; }-+ InputInfo.IsCatchDefaultEnable = mOptions.IsCatchDefaultEnable; if (mOptions.HasOverrideClassGuid) { InputInfo.OverrideClassGuid = &mOptions.OverrideClassGuid; } else {@@ -937,5 +939,3 @@ main ( return GetUtilityStatus (); }--diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.h b/BaseTools/Source/C/VfrCompile/VfrCompiler.h index b6e207d2ce..974f37c4eb 100644 --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.h +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.h @@ -52,6 +52,7 @@ typedef struct { BOOLEAN WarningAsError; BOOLEAN AutoDefault; BOOLEAN CheckDefault;+ BOOLEAN IsCatchDefaultEnable; } OPTIONS; typedef enum {diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp b/BaseTools/Source/C/VfrCompile/VfrError.cpp index 65bb8e34fd..8a706f929b 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp @@ -49,7 +49,8 @@ static SVFR_WARNING_HANDLE VFR_WARNING_HANDLE_TABLE [] = { { VFR_WARNING_DEFAULT_VALUE_REDEFINED, ": default value re-defined with different value"}, { VFR_WARNING_ACTION_WITH_TEXT_TWO, ": Action opcode should not have TextTwo part"}, { VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE, ": Not recommend to use obsoleted framework opcode"},- { VFR_WARNING_CODEUNDEFINED, ": undefined Warning Code" }+ { VFR_WARNING_CODEUNDEFINED, ": undefined Warning Code" },+ { VFR_WARNING_UNSUPPORTED, ": pls remove the default values if necessary" } }; CVfrErrorHandle::CVfrErrorHandle (diff --git a/BaseTools/Source/C/VfrCompile/VfrError.h b/BaseTools/Source/C/VfrCompile/VfrError.h index 7d16bd5f74..1b4bc173d2 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.h +++ b/BaseTools/Source/C/VfrCompile/VfrError.h @@ -47,7 +47,8 @@ typedef enum { VFR_WARNING_DEFAULT_VALUE_REDEFINED = 0, VFR_WARNING_ACTION_WITH_TEXT_TWO, VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE,- VFR_WARNING_CODEUNDEFINED+ VFR_WARNING_CODEUNDEFINED,+ VFR_WARNING_UNSUPPORTED } EFI_VFR_WARNING_CODE; typedef struct _SVFR_ERROR_HANDLE {diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h index 9ef6f07787..d8fada3bcb 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h @@ -96,6 +96,7 @@ struct SBufferNode { typedef struct { EFI_GUID *OverrideClassGuid;+ BOOLEAN IsCatchDefaultEnable; } INPUT_INFO_TO_SYNTAX; class CFormPkg {diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index 55fd067f8a..d7376122d8 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -50,6 +50,7 @@ VfrParserStart ( { ParserBlackBox<CVfrDLGLexer, EfiVfrParser, ANTLRToken> VfrParser(File); VfrParser.parser()->SetOverrideClassGuid (InputInfo->OverrideClassGuid);+ VfrParser.parser()->SetIsCatchDefaultEnable(InputInfo->IsCatchDefaultEnable); return VfrParser.parser()->vfrProgram(); } >>@@ -975,7 +976,15 @@ vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize, vfrStatementDefaultStore : << UINT16 DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; >>- D:DefaultStore N:StringIdentifier ","+ D:DefaultStore N:StringIdentifier "," <<+ if (mIsCatchDefaultEnable) {+ gCVfrErrorHandle.HandleWarning (+ VFR_WARNING_UNSUPPORTED,+ D->getLine(),+ D->getText()+ );+ }+ >> Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" { "," Attribute "=" A:Number << DefaultId = _STOU16(A->getText(), A->getLine()); >>@@ -1775,7 +1784,11 @@ vfrStatementDefault : CIfrNumeric *NumericQst = NULL; >>- D:Default + D:Default <<+ if (mIsCatchDefaultEnable) {+ DefaultValueError(VFR_RETURN_UNSUPPORTED, D->getLine());+ }+ >> ( ( "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE(), *Val, ArrayType] "," @@ -1970,11 +1983,15 @@ vfrStatementInvalid : ; flagsField :- Number - | InteractiveFlag - | ManufacturingFlag - | DefaultFlag - | ResetRequiredFlag + Number+ | InteractiveFlag+ | ManufacturingFlag+ | D:DefaultFlag <<+ if (mIsCatchDefaultEnable) {+ DefaultValueError(VFR_RETURN_UNSUPPORTED, D->getLine());+ }+ >>+ | ResetRequiredFlag | ReconnectRequiredFlag | N:NVAccessFlag << gCVfrErrorHandle.HandleWarning (@@ -3790,7 +3807,12 @@ oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] : | RestStyleFlag << $HFlags |= 0x20; >> | ReconnectRequiredFlag << $HFlags |= 0x40; >> | ManufacturingFlag << $LFlags |= 0x20; >>- | DefaultFlag << $LFlags |= 0x10; >>+ | D:DefaultFlag <<+ $LFlags |= 0x10;+ if (mIsCatchDefaultEnable) {+ DefaultValueError(VFR_RETURN_UNSUPPORTED, D->getLine());+ }+ >> | A:NVAccessFlag << gCVfrErrorHandle.HandleWarning ( VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE,@@ -4837,6 +4859,7 @@ spanFlags [UINT8 & Flags] : class EfiVfrParser { << private:+ BOOLEAN mIsCatchDefaultEnable; UINT8 mParserStatus; BOOLEAN mConstantOnlyInExpression; @@ -4880,6 +4903,7 @@ public: VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr); VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32); VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN CONST CHAR8 *);+ VOID DefaultValueError (IN EFI_VFR_RETURN_CODE, IN UINT32); VOID syn (ANTLRAbstractToken *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32); @@ -4909,6 +4933,7 @@ public: VOID IdEqIdDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_COMPARE_TYPE); VOID IdEqListDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN UINT16 *); VOID SetOverrideClassGuid (IN EFI_GUID *);+ VOID SetIsCatchDefaultEnable (BOOLEAN IsCatchDefaultEnable); >> } @@ -5086,6 +5111,17 @@ EfiVfrParser::_PCATCH ( mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, (CHAR8 *) ErrorMsg); } +VOID+EfiVfrParser::DefaultValueError (+ IN EFI_VFR_RETURN_CODE ReturnCode,+ IN UINT32 LineNum+ )+{+ CHAR8 ErrorMsg[100];+ sprintf(ErrorMsg, "please remove the default value / defaultstore in line %d", LineNum);+ mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, ErrorMsg);+}+ VOID EfiVfrParser::syn ( ANTLRAbstractToken *Tok,@@ -5688,6 +5724,12 @@ EfiVfrParser::SetOverrideClassGuid (IN EFI_GUID *OverrideClassGuid) mOverrideClassGuid = OverrideClassGuid; } +VOID+EfiVfrParser::SetIsCatchDefaultEnable (BOOLEAN IsCatchDefaultEnable)+{+ mIsCatchDefaultEnable = IsCatchDefaultEnable;+}+ VOID EfiVfrParser::CheckDuplicateDefaultValue ( IN EFI_DEFAULT_ID DefaultId,-- 2.39.1.windows.1 -=-=-=-=-=-= Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116948): https://edk2.groups.io/g/devel/message/116948 Mute This Topic: https://groups.io/mt/105061128/7976666 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [yuting2.yang@intel.com] -=-=-=-=-=-= -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117214): https://edk2.groups.io/g/devel/message/117214 Mute This Topic: https://groups.io/mt/105061128/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply related [flat|nested] 3+ messages in thread
* 回复: [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds DefaultValueError 2024-03-28 7:28 ` Zhang, Zifeng @ 2024-04-02 1:09 ` gaoliming via groups.io 0 siblings, 0 replies; 3+ messages in thread From: gaoliming via groups.io @ 2024-04-02 1:09 UTC (permalink / raw) To: devel, zifeng.zhang, 'Yang, Yuting2' Cc: 'Chen, Christine', 'Feng, Bob C', 'He, Haiyang' Zifang and Yuting: The change looks good. But, there are two ways for error report. One is gCVfrErrorHandle.HandleWarning, another is DefaultValueError. Can we always use gCVfrErrorHandle.HandleWarning? Thanks Liming > -----邮件原件----- > 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Zhang, Zifeng > 发送时间: 2024年3月28日 15:29 > 收件人: Yang, Yuting2 <yuting2.yang@intel.com>; devel@edk2.groups.io; > gaoliming <gaoliming@byosoft.com.cn> > 抄送: Chen, Christine <yuwei.chen@intel.com>; Feng, Bob C > <bob.c.feng@intel.com>; He, Haiyang <haiyang.he@intel.com> > 主题: Re: [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds > DefaultValueError > > Thanks Yuting for patch update! > > Hi @gaoliming, > Would you like to review the V4 patch? > Hope to merge it asap to avoid blocking feature complete. > > Best Regards, > Zifeng > > -----Original Message----- > From: Yang, Yuting2 <yuting2.yang@intel.com> > Sent: Thursday, March 21, 2024 3:54 PM > To: devel@edk2.groups.io; gaoliming <gaoliming@byosoft.com.cn> > Cc: Chen, Christine <yuwei.chen@intel.com>; Zhang, Zifeng > <zifeng.zhang@intel.com>; Feng, Bob C <bob.c.feng@intel.com>; He, Haiyang > <haiyang.he@intel.com> > Subject: RE: [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds > DefaultValueError > > Hi liming, > > Gentle reminder, we have removed the whitespace. Please help review the > patch~ > > Thanks, > Yuting > > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yuting > Yang > Sent: Thursday, March 21, 2024 3:30 PM > To: devel@edk2.groups.io > Cc: Rebecca Cran <rebecca@bsdio.com>; Liming Gao > <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>; Chen, > Christine <yuwei.chen@intel.com>; Zhang, Zifeng <zifeng.zhang@intel.com> > Subject: [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds > DefaultValueError > > Add --catch_default option > Raise a DefaultValueError when encountering VFR default definitions to help > remove default variables. > > Signed-off-by: Yuting Yang <yuting2.yang@intel.com> > > Cc: Rebecca Cran <rebecca@bsdio.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Cc: Bob Feng <bob.c.feng@intel.com> > Cc: Christine Chen <yuwei.chen@intel.com> > Cc: Zifeng Zhang <zifeng.zhang@intel.com> > --- > BaseTools/Source/C/VfrCompile/VfrCompiler.cpp | 8 ++++---- > BaseTools/Source/C/VfrCompile/VfrCompiler.h | 1 + > BaseTools/Source/C/VfrCompile/VfrError.cpp | 3 ++- > BaseTools/Source/C/VfrCompile/VfrError.h | 3 ++- > BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 1 + > BaseTools/Source/C/VfrCompile/VfrSyntax.g | 58 > ++++++++++++++++++++++++++++++++++++++++++++++++++-------- > 6 files changed, 60 insertions(+), 14 deletions(-) > > diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp > b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp > index 5f4d262d85..4031af6e39 100644 > --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp > +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp > @@ -78,6 +78,7 @@ CVfrCompiler::OptionInitialization ( > mOptions.WarningAsError = FALSE; > mOptions.AutoDefault = FALSE; > mOptions.CheckDefault = FALSE;+ > mOptions.IsCatchDefaultEnable = FALSE; memset > (&mOptions.OverrideClassGuid, 0, sizeof (EFI_GUID)); if (Argc == 1) {@@ > -95,6 +96,8 @@ CVfrCompiler::OptionInitialization ( > Version (); SET_RUN_STATUS (STATUS_DEAD); > return;+ } else if (stricmp(Argv[Index], "--catch_default") == 0){+ > mOptions.IsCatchDefaultEnable = TRUE; } else if (stricmp(Argv[Index], > "-l") == 0) { mOptions.CreateRecordListFile = TRUE; > gCIfrRecordInfoDB.TurnOn ();@@ -179,7 +182,6 @@ > CVfrCompiler::OptionInitialization ( > goto Fail; } strcpy (mOptions.VfrFileName, Argv[Index]);- > if (mOptions.OutputDirectory == NULL) { mOptions.OutputDirectory = > (CHAR8 *) malloc (1); if (mOptions.OutputDirectory == NULL) {@@ > -679,7 +681,7 @@ CVfrCompiler::Compile ( > DebugError (NULL, 0, 0001, "Error opening the input file", "%s", > InFileName); goto Fail; }-+ InputInfo.IsCatchDefaultEnable = > mOptions.IsCatchDefaultEnable; if (mOptions.HasOverrideClassGuid) > { InputInfo.OverrideClassGuid = &mOptions.OverrideClassGuid; } else > {@@ -937,5 +939,3 @@ main ( > return GetUtilityStatus (); }--diff --git > a/BaseTools/Source/C/VfrCompile/VfrCompiler.h > b/BaseTools/Source/C/VfrCompile/VfrCompiler.h > index b6e207d2ce..974f37c4eb 100644 > --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.h > +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.h > @@ -52,6 +52,7 @@ typedef struct { > BOOLEAN WarningAsError; BOOLEAN AutoDefault; BOOLEAN > CheckDefault;+ BOOLEAN IsCatchDefaultEnable; } OPTIONS; typedef > enum {diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp > b/BaseTools/Source/C/VfrCompile/VfrError.cpp > index 65bb8e34fd..8a706f929b 100644 > --- a/BaseTools/Source/C/VfrCompile/VfrError.cpp > +++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp > @@ -49,7 +49,8 @@ static SVFR_WARNING_HANDLE > VFR_WARNING_HANDLE_TABLE [] = { > { VFR_WARNING_DEFAULT_VALUE_REDEFINED, ": default value > re-defined with different value"}, > { VFR_WARNING_ACTION_WITH_TEXT_TWO, ": Action opcode should not > have TextTwo part"}, > { VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE, ": Not recommend to > use obsoleted framework opcode"},- { VFR_WARNING_CODEUNDEFINED, ": > undefined Warning Code" }+ { VFR_WARNING_CODEUNDEFINED, ": > undefined Warning Code" },+ { VFR_WARNING_UNSUPPORTED, ": pls > remove the default values if necessary" } }; > CVfrErrorHandle::CVfrErrorHandle (diff --git > a/BaseTools/Source/C/VfrCompile/VfrError.h > b/BaseTools/Source/C/VfrCompile/VfrError.h > index 7d16bd5f74..1b4bc173d2 100644 > --- a/BaseTools/Source/C/VfrCompile/VfrError.h > +++ b/BaseTools/Source/C/VfrCompile/VfrError.h > @@ -47,7 +47,8 @@ typedef enum { > VFR_WARNING_DEFAULT_VALUE_REDEFINED = 0, > VFR_WARNING_ACTION_WITH_TEXT_TWO, > VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE,- > VFR_WARNING_CODEUNDEFINED+ VFR_WARNING_CODEUNDEFINED,+ > VFR_WARNING_UNSUPPORTED } EFI_VFR_WARNING_CODE; typedef > struct _SVFR_ERROR_HANDLE {diff --git > a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h > b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h > index 9ef6f07787..d8fada3bcb 100644 > --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h > +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h > @@ -96,6 +96,7 @@ struct SBufferNode { > typedef struct { EFI_GUID *OverrideClassGuid;+ BOOLEAN > IsCatchDefaultEnable; } INPUT_INFO_TO_SYNTAX; class CFormPkg {diff --git > a/BaseTools/Source/C/VfrCompile/VfrSyntax.g > b/BaseTools/Source/C/VfrCompile/VfrSyntax.g > index 55fd067f8a..d7376122d8 100644 > --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g > +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g > @@ -50,6 +50,7 @@ VfrParserStart ( > { ParserBlackBox<CVfrDLGLexer, EfiVfrParser, ANTLRToken> > VfrParser(File); VfrParser.parser()->SetOverrideClassGuid > (InputInfo->OverrideClassGuid);+ > VfrParser.parser()->SetIsCatchDefaultEnable(InputInfo->IsCatchDefaultEnable > ); return VfrParser.parser()->vfrProgram(); } >>@@ -975,7 +976,15 @@ > vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 > TypeSize, > vfrStatementDefaultStore : << UINT16 DefaultId = > EFI_HII_DEFAULT_CLASS_STANDARD; >>- D:DefaultStore N:StringIdentifier > ","+ D:DefaultStore N:StringIdentifier "," <<+ > if (mIsCatchDefaultEnable) {+ > gCVfrErrorHandle.HandleWarning (+ > VFR_WARNING_UNSUPPORTED,+ > D->getLine(),+ > D->getText()+ > );+ > }+ >> > Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" { "," Attribute "=" > A:Number << DefaultId = _STOU16(A->getText(), > A->getLine()); >>@@ -1775,7 +1784,11 @@ vfrStatementDefault : > CIfrNumeric *NumericQst = NULL; >>- > D:Default + D:Default > <<+ if > (mIsCatchDefaultEnable) {+ > DefaultValueError(VFR_RETURN_UNSUPPORTED, > D->getLine());+ > }+ >> > ( ( "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE(), > *Val, ArrayType] "," @@ -1970,11 +1983,15 @@ vfrStatementInvalid : > ; flagsField :- Number - | InteractiveFlag - | ManufacturingFlag - > | DefaultFlag - | ResetRequiredFlag + Number+ | InteractiveFlag+ | > ManufacturingFlag+ | D:DefaultFlag > <<+ if > (mIsCatchDefaultEnable) {+ > DefaultValueError(VFR_RETURN_UNSUPPORTED, > D->getLine());+ > }+ > >>+ | ResetRequiredFlag | ReconnectRequiredFlag | > N:NVAccessFlag << > gCVfrErrorHandle.HandleWarning (@@ -3790,7 +3807,12 @@ > oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] : > | RestStyleFlag << $HFlags > |= 0x20; >> | ReconnectRequiredFlag > << $HFlags |= 0x40; >> | ManufacturingFlag > << $LFlags |= 0x20; >>- | DefaultFlag > << $LFlags |= 0x10; >>+ | D:DefaultFlag > <<+ > $LFlags |= 0x10;+ > if (mIsCatchDefaultEnable) {+ > DefaultValueError(VFR_RETURN_UNSUPPORTED, > D->getLine());+ > }+ > >> | A:NVAccessFlag > << > gCVfrErrorHandle.HandleWarning > ( > VFR_WARNING_OBSOLETED_FRAMEWORK_OPCODE,@@ -4837,6 +4859,7 > @@ spanFlags [UINT8 & Flags] : > class EfiVfrParser { << private:+ BOOLEAN > mIsCatchDefaultEnable; UINT8 mParserStatus; > BOOLEAN mConstantOnlyInExpression; @@ -4880,6 +4903,7 > @@ public: > VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN > ANTLRTokenPtr); VOID _PCATCH (IN > EFI_VFR_RETURN_CODE, IN UINT32); VOID _PCATCH > (IN EFI_VFR_RETURN_CODE, IN UINT32, IN CONST CHAR8 *);+ VOID > DefaultValueError (IN EFI_VFR_RETURN_CODE, IN UINT32); VOID > syn (ANTLRAbstractToken *, ANTLRChar *, SetWordType *, > ANTLRTokenType, INT32); @@ -4909,6 +4933,7 @@ public: > VOID IdEqIdDoSpecial (IN UINT32 &, IN > UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_QUESTION_ID, > IN CHAR8 *, IN UINT32, IN EFI_COMPARE_TYPE); VOID > IdEqListDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN > CHAR8 *, IN UINT32, IN UINT16, IN UINT16 *); VOID > SetOverrideClassGuid (IN EFI_GUID *);+ VOID > SetIsCatchDefaultEnable (BOOLEAN IsCatchDefaultEnable); >> } @@ -5086,6 > +5111,17 @@ EfiVfrParser::_PCATCH ( > mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError > (ReturnCode, LineNum, (CHAR8 *) ErrorMsg); } > +VOID+EfiVfrParser::DefaultValueError (+ IN EFI_VFR_RETURN_CODE > ReturnCode,+ IN UINT32 LineNum+ )+{+ CHAR8 > ErrorMsg[100];+ sprintf(ErrorMsg, "please remove the default value / > defaultstore in line %d", LineNum);+ mParserStatus = mParserStatus + > gCVfrErrorHandle.HandleError (ReturnCode, LineNum, ErrorMsg);+}+ VOID > EfiVfrParser::syn ( ANTLRAbstractToken *Tok,@@ -5688,6 +5724,12 @@ > EfiVfrParser::SetOverrideClassGuid (IN EFI_GUID *OverrideClassGuid) > mOverrideClassGuid = OverrideClassGuid; } > +VOID+EfiVfrParser::SetIsCatchDefaultEnable (BOOLEAN > IsCatchDefaultEnable)+{+ mIsCatchDefaultEnable = > IsCatchDefaultEnable;+}+ VOID EfiVfrParser::CheckDuplicateDefaultValue > ( IN EFI_DEFAULT_ID DefaultId,-- > 2.39.1.windows.1 > > > > -=-=-=-=-=-= > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#116948): > https://edk2.groups.io/g/devel/message/116948 > Mute This Topic: https://groups.io/mt/105061128/7976666 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [yuting2.yang@intel.com] > -=-=-=-=-=-= > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117300): https://edk2.groups.io/g/devel/message/117300 Mute This Topic: https://groups.io/mt/105279854/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-02 1:09 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <17BEB716C0DD8A75.2828@groups.io> 2024-03-21 7:54 ` [edk2-devel] [Patch V4] BaseTools: VfrCompiler Adds DefaultValueError Yuting Yang 2024-03-28 7:28 ` Zhang, Zifeng 2024-04-02 1:09 ` 回复: " gaoliming via groups.io
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox