Discussion:
[edk2] [PATCH] MdeModulePkg Variable: Minor enhancement to VarCheck
Star Zeng
2015-07-01 07:30:47 UTC
Permalink
1. When Property->Attributes == 0, don't check input Attributes.
2. Enhance comments to be indent aligned and debug message
to be aligned with other messages.

Cc: Jiewen Yao <***@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <***@intel.com>
---
.../Universal/Variable/RuntimeDxe/VarCheck.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
index ab0c1d6..044dfc6 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
@@ -809,28 +809,28 @@ InternalVarCheckSetVariableCheck (
if (Property == NULL) {
Status = GetUefiDefinedVariableProperty (VariableName, VendorGuid, TRUE, &Property, &VarCheckFunction);
if (EFI_ERROR (Status)) {
- //
- // To prevent name collisions with possible future globally defined variables,
- // other internal firmware data variables that are not defined here must be
- // saved with a unique VendorGuid other than EFI_GLOBAL_VARIABLE or
- // any other GUID defined by the UEFI Specification. Implementations must
- // only permit the creation of variables with a UEFI Specification-defined
- // VendorGuid when these variables are documented in the UEFI Specification.
- //
+ //
+ // To prevent name collisions with possible future globally defined variables,
+ // other internal firmware data variables that are not defined here must be
+ // saved with a unique VendorGuid other than EFI_GLOBAL_VARIABLE or
+ // any other GUID defined by the UEFI Specification. Implementations must
+ // only permit the creation of variables with a UEFI Specification-defined
+ // VendorGuid when these variables are documented in the UEFI Specification.
+ //
DEBUG ((EFI_D_INFO, "Variable Check UEFI defined variable fail %r - %s not in %g namespace\n", Status, VariableName, VendorGuid));
return Status;
}
}
if (Property != NULL) {
if (mEnableLocking && ((Property->Property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) != 0)) {
- DEBUG ((EFI_D_INFO, "[Variable]: Var Check ReadOnly variable fail %r - %g:%s\n", EFI_WRITE_PROTECTED, VendorGuid, VariableName));
+ DEBUG ((EFI_D_INFO, "Variable Check ReadOnly variable fail %r - %g:%s\n", EFI_WRITE_PROTECTED, VendorGuid, VariableName));
return EFI_WRITE_PROTECTED;
}
if (!((((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0) && (DataSize == 0)) || (Attributes == 0))) {
//
// Not to delete variable.
//
- if ((Attributes != 0) && ((Attributes & (~EFI_VARIABLE_APPEND_WRITE)) != Property->Attributes)) {
+ if ((Property->Attributes != 0) && ((Attributes & (~EFI_VARIABLE_APPEND_WRITE)) != Property->Attributes)) {
DEBUG ((EFI_D_INFO, "Variable Check Attributes(0x%08x to 0x%08x) fail %r - %g:%s\n", Property->Attributes, Attributes, EFI_INVALID_PARAMETER, VendorGuid, VariableName));
return EFI_INVALID_PARAMETER;
}
--
1.9.5.msysgit.0
Yao, Jiewen
2015-07-01 07:33:44 UTC
Permalink
Looks good.

Reviewed-by: Yao, Jiewen <***@intel.com>

-----Original Message-----
From: Zeng, Star
Sent: Wednesday, July 01, 2015 3:31 PM
To: edk2-***@lists.sourceforge.net
Cc: Yao, Jiewen
Subject: [PATCH] MdeModulePkg Variable: Minor enhancement to VarCheck

1. When Property->Attributes == 0, don't check input Attributes.
2. Enhance comments to be indent aligned and debug message to be aligned with other messages.

Cc: Jiewen Yao <***@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <***@intel.com>
---
.../Universal/Variable/RuntimeDxe/VarCheck.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
index ab0c1d6..044dfc6 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VarCheck.c
@@ -809,28 +809,28 @@ InternalVarCheckSetVariableCheck (
if (Property == NULL) {
Status = GetUefiDefinedVariableProperty (VariableName, VendorGuid, TRUE, &Property, &VarCheckFunction);
if (EFI_ERROR (Status)) {
- //
- // To prevent name collisions with possible future globally defined variables,
- // other internal firmware data variables that are not defined here must be
- // saved with a unique VendorGuid other than EFI_GLOBAL_VARIABLE or
- // any other GUID defined by the UEFI Specification. Implementations must
- // only permit the creation of variables with a UEFI Specification-defined
- // VendorGuid when these variables are documented in the UEFI Specification.
- //
+ //
+ // To prevent name collisions with possible future globally defined variables,
+ // other internal firmware data variables that are not defined here must be
+ // saved with a unique VendorGuid other than EFI_GLOBAL_VARIABLE or
+ // any other GUID defined by the UEFI Specification. Implementations must
+ // only permit the creation of variables with a UEFI Specification-defined
+ // VendorGuid when these variables are documented in the UEFI Specification.
+ //
DEBUG ((EFI_D_INFO, "Variable Check UEFI defined variable fail %r - %s not in %g namespace\n", Status, VariableName, VendorGuid));
return Status;
}
}
if (Property != NULL) {
if (mEnableLocking && ((Property->Property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) != 0)) {
- DEBUG ((EFI_D_INFO, "[Variable]: Var Check ReadOnly variable fail %r - %g:%s\n", EFI_WRITE_PROTECTED, VendorGuid, VariableName));
+ DEBUG ((EFI_D_INFO, "Variable Check ReadOnly variable fail %r -
+ %g:%s\n", EFI_WRITE_PROTECTED, VendorGuid, VariableName));
return EFI_WRITE_PROTECTED;
}
if (!((((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0) && (DataSize == 0)) || (Attributes == 0))) {
//
// Not to delete variable.
//
- if ((Attributes != 0) && ((Attributes & (~EFI_VARIABLE_APPEND_WRITE)) != Property->Attributes)) {
+ if ((Property->Attributes != 0) && ((Attributes &
+ (~EFI_VARIABLE_APPEND_WRITE)) != Property->Attributes)) {
DEBUG ((EFI_D_INFO, "Variable Check Attributes(0x%08x to 0x%08x) fail %r - %g:%s\n", Property->Attributes, Attributes, EFI_INVALID_PARAMETER, VendorGuid, VariableName));
return EFI_INVALID_PARAMETER;
}
--
1.9.5.msysgit.0

Loading...