diff options
author | yshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-01-11 03:16:46 +0000 |
---|---|---|
committer | yshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-01-11 03:16:46 +0000 |
commit | ab5f0d6d1271a293979af569a269792c491d0893 (patch) | |
tree | e8ebb9e8dcb8f48b0279aead40e6ccd428da65a4 /IntelFrameworkModulePkg/Universal/VariablePei | |
parent | 9cad030bc14e706d8986ed33f0fa8b28f0828c48 (diff) | |
download | edk2-platforms-ab5f0d6d1271a293979af569a269792c491d0893.tar.xz |
Change C functions, xxxSizeOfVariable(), to MACRO, which can avoid the ICC compile error "Unspecific evaluated order".
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4552 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg/Universal/VariablePei')
-rw-r--r-- | IntelFrameworkModulePkg/Universal/VariablePei/Variable.c | 65 | ||||
-rw-r--r-- | IntelFrameworkModulePkg/Universal/VariablePei/Variable.h | 18 |
2 files changed, 23 insertions, 60 deletions
diff --git a/IntelFrameworkModulePkg/Universal/VariablePei/Variable.c b/IntelFrameworkModulePkg/Universal/VariablePei/Variable.c index e050fbcf9d..3751845fbf 100644 --- a/IntelFrameworkModulePkg/Universal/VariablePei/Variable.c +++ b/IntelFrameworkModulePkg/Universal/VariablePei/Variable.c @@ -80,59 +80,6 @@ Returns: }
-
-UINT32
-NameSizeOfVariable (
- IN VARIABLE_HEADER *Variable
- )
-{
- //
- // Check whether the header is valid fully;
- // Tricky: The unprogramed data in FLASH equals 0xff.
- //
- if (Variable->DataSize == (UINT32) -1 ||
- Variable->Attributes == (UINT32) -1 ||
- Variable->NameSize == (UINT32) -1) {
- return 0;
- }
- return Variable->NameSize;
-}
-
-UINT32
-DataSizeOfVariable (
- IN VARIABLE_HEADER *Variable
- )
-{
- //
- // Check whether the header is valid fully;
- // Tricky: The unprogramed data in FLASH equals 0xff.
- //
- if (Variable->DataSize == (UINT32) -1 ||
- Variable->Attributes == (UINT32) -1 ||
- Variable->NameSize == (UINT32) -1) {
- return 0;
- }
- return Variable->DataSize;
-}
-
-UINT32
-AttributesOfVariable (
- IN VARIABLE_HEADER *Variable
- )
-{
-
- //
- // Check whether the header is valid fully;
- // Tricky: The unprogramed data in FLASH equals 0xff.
- //
- if (Variable->DataSize == (UINT32) -1 ||
- Variable->Attributes == (UINT32) -1 ||
- Variable->NameSize == (UINT32) -1) {
- return 0;
- }
- return Variable->Attributes;
-}
-
STATIC
VARIABLE_HEADER *
GetNextVariablePtr (
@@ -153,7 +100,7 @@ Returns: --*/
{
- return (VARIABLE_HEADER *) HEADER_ALIGN ((UINTN) GET_VARIABLE_DATA_PTR (Variable) + DataSizeOfVariable (Variable) + GET_PAD_SIZE (DataSizeOfVariable (Variable)));
+ return (VARIABLE_HEADER *) HEADER_ALIGN ((UINTN) GET_VARIABLE_DATA_PTR (Variable) + DATASIZE_OF_VARIABLE (Variable) + GET_PAD_SIZE (DATASIZE_OF_VARIABLE (Variable)));
}
STATIC
@@ -271,8 +218,8 @@ Returns: (((INT32 *) VendorGuid)[2] == ((INT32 *) &Variable->VendorGuid)[2]) &&
(((INT32 *) VendorGuid)[3] == ((INT32 *) &Variable->VendorGuid)[3])
) {
- ASSERT (NameSizeOfVariable (Variable) != 0);
- if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable), NameSizeOfVariable (Variable))) {
+ ASSERT (NAMESIZE_OF_VARIABLE (Variable) != 0);
+ if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable), NAMESIZE_OF_VARIABLE (Variable))) {
PtrTrack->CurrPtr = Variable;
return EFI_SUCCESS;
}
@@ -479,7 +426,7 @@ Returns: //
// Get data size
//
- VarDataSize = DataSizeOfVariable (Variable.CurrPtr);
+ VarDataSize = DATASIZE_OF_VARIABLE (Variable.CurrPtr);
if (*DataSize >= VarDataSize) {
(*PeiServices)->CopyMem (Data, GET_VARIABLE_DATA_PTR (Variable.CurrPtr), VarDataSize);
@@ -605,9 +552,9 @@ Returns: while (!(Variable.CurrPtr >= Variable.EndPtr || Variable.CurrPtr == NULL)) {
if (IsValidVariableHeader (Variable.CurrPtr)) {
if (Variable.CurrPtr->State == VAR_ADDED) {
- ASSERT (NameSizeOfVariable (Variable.CurrPtr) != 0);
+ ASSERT (NAMESIZE_OF_VARIABLE (Variable.CurrPtr) != 0);
- VarNameSize = (UINTN) NameSizeOfVariable (Variable.CurrPtr);
+ VarNameSize = (UINTN) NAMESIZE_OF_VARIABLE (Variable.CurrPtr);
if (VarNameSize <= *VariableNameSize) {
(*PeiServices)->CopyMem (VariableName, GET_VARIABLE_NAME_PTR (Variable.CurrPtr), VarNameSize);
diff --git a/IntelFrameworkModulePkg/Universal/VariablePei/Variable.h b/IntelFrameworkModulePkg/Universal/VariablePei/Variable.h index aeb49bca80..2f586c6f4a 100644 --- a/IntelFrameworkModulePkg/Universal/VariablePei/Variable.h +++ b/IntelFrameworkModulePkg/Universal/VariablePei/Variable.h @@ -44,10 +44,26 @@ Abstract: #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
+#define NAMESIZE_OF_VARIABLE(Variable) \
+ ((((Variable)->DataSize == (UINT32) -1) || \
+ ((Variable)->Attributes == (UINT32) -1) || \
+ ((Variable)->NameSize == (UINT32) -1)) ? \
+ 0 : \
+ (Variable)->NameSize \
+ )
+
+#define DATASIZE_OF_VARIABLE(Variable) \
+ ((((Variable)->DataSize == (UINT32) -1) || \
+ ((Variable)->Attributes == (UINT32) -1) || \
+ ((Variable)->NameSize == (UINT32) -1)) ? \
+ 0 : \
+ (Variable)->DataSize \
+ )
+
#define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
#define GET_VARIABLE_DATA_PTR(a) \
- (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (a) + NameSizeOfVariable(a) + GET_PAD_SIZE (NameSizeOfVariable(a) ))
+ (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (a) + NAMESIZE_OF_VARIABLE(a) + GET_PAD_SIZE (NAMESIZE_OF_VARIABLE(a)))
typedef struct {
VARIABLE_HEADER *CurrPtr;
|