]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
1. Move ASSERT to proper place.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Expression.c
index 46f70b986bb5064ab95907d91f4df0502b7489fa..fc687540be37d7e1229b6ec9b7541f679da7b049 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Utility functions for expression evaluation.\r
 \r
-Copyright (c) 2007, Intel Corporation\r
+Copyright (c) 2007 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -79,7 +79,7 @@ GrowStack (
     //\r
     // Free The Old Stack\r
     //\r
-    gBS->FreePool (*Stack);\r
+    FreePool (*Stack);\r
   }\r
 \r
   //\r
@@ -421,6 +421,14 @@ IdToQuestion (
 \r
     Question = IdToQuestion2 (Form, QuestionId);\r
     if (Question != NULL) {\r
+      //\r
+      // EFI variable storage may be updated by Callback() asynchronous,\r
+      // to keep synchronous, always reload the Question Value.\r
+      //\r
+      if (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {\r
+        GetQuestionValue (FormSet, Form, Question, FALSE);\r
+      }\r
+\r
       return Question;\r
     }\r
 \r
@@ -611,7 +619,6 @@ IfrToUint (
   EFI_HII_VALUE  Value;\r
   CHAR16         *String;\r
   CHAR16         *StringPtr;\r
-  UINTN          BufferSize;\r
 \r
   Status = PopExpression (&Value);\r
   if (EFI_ERROR (Status)) {\r
@@ -628,21 +635,21 @@ IfrToUint (
     if (String == NULL) {\r
       return EFI_NOT_FOUND;\r
     }\r
-\r
+    \r
     IfrStrToUpper (String);\r
     StringPtr = StrStr (String, L"0X");\r
     if (StringPtr != NULL) {\r
       //\r
       // Hex string\r
       //\r
-      BufferSize = sizeof (UINT64);\r
-      Status = HexStringToBuf ((UINT8 *) &Result->Value.u64, &BufferSize, StringPtr + 2, NULL);\r
+      Result->Value.u64 = StrHexToUint64 (String);\r
     } else {\r
       //\r
-      // BUGBUG: Need handle decimal string\r
+      // decimal string\r
       //\r
+      Result->Value.u64 = StrDecimalToUint64 (String);\r
     }\r
-    gBS->FreePool (String);\r
+    FreePool (String);\r
   } else {\r
     CopyMem (Result, &Value, sizeof (EFI_HII_VALUE));\r
   }\r
@@ -696,7 +703,7 @@ IfrCatenate (
     }\r
 \r
     String[Index] = GetToken (Value.Value.string, FormSet->HiiHandle);\r
-    if (String== NULL) {\r
+    if (String[Index] == NULL) {\r
       Status = EFI_NOT_FOUND;\r
       goto Done;\r
     }\r
@@ -766,7 +773,7 @@ IfrMatch (
     }\r
 \r
     String[Index] = GetToken (Value.Value.string, FormSet->HiiHandle);\r
-    if (String== NULL) {\r
+    if (String [Index] == NULL) {\r
       Status = EFI_NOT_FOUND;\r
       goto Done;\r
     }\r
@@ -843,7 +850,7 @@ IfrFind (
     }\r
 \r
     String[Index] = GetToken (Value.Value.string, FormSet->HiiHandle);\r
-    if (String== NULL) {\r
+    if (String[Index] == NULL) {\r
       Status = EFI_NOT_FOUND;\r
       goto Done;\r
     }\r
@@ -941,7 +948,7 @@ IfrMid (
   Result->Type = EFI_IFR_TYPE_STRING;\r
   Result->Value.string = NewString (SubString, FormSet->HiiHandle);\r
 \r
-  gBS->FreePool (String);\r
+  FreePool (String);\r
 \r
   return Status;\r
 }\r
@@ -999,7 +1006,7 @@ IfrToken (
     }\r
 \r
     String[Index] = GetToken (Value.Value.string, FormSet->HiiHandle);\r
-    if (String== NULL) {\r
+    if (String[Index] == NULL) {\r
       Status = EFI_NOT_FOUND;\r
       goto Done;\r
     }\r
@@ -1104,7 +1111,7 @@ IfrSpan (
     }\r
 \r
     String[Index] = GetToken (Value.Value.string, FormSet->HiiHandle);\r
-    if (String== NULL) {\r
+    if (String [Index] == NULL) {\r
       Status = EFI_NOT_FOUND;\r
       goto Done;\r
     }\r
@@ -1263,14 +1270,14 @@ CompareHiiValue (
 \r
     Str2 = GetToken (Value2->Value.string, HiiHandle);\r
     if (Str2 == NULL) {\r
-      gBS->FreePool (Str1);\r
+      FreePool (Str1);\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
     Result = StrCmp (Str1, Str2);\r
 \r
-    gBS->FreePool (Str1);\r
-    gBS->FreePool (Str2);\r
+    FreePool (Str1);\r
+    FreePool (Str2);\r
 \r
     return Result;\r
   }\r
@@ -1292,7 +1299,9 @@ CompareHiiValue (
 \r
 \r
 /**\r
-  Evaluate the result of a HII expression\r
+  Evaluate the result of a HII expression.\r
+\r
+  If Expression is NULL, then ASSERT.\r
 \r
   @param  FormSet                FormSet associated with this expression.\r
   @param  Form                   Form associated with this expression.\r
@@ -1334,6 +1343,7 @@ EvaluateExpression (
   //\r
   ResetExpressionStack ();\r
 \r
+  ASSERT (Expression != NULL);\r
   Expression->Result.Type = EFI_IFR_TYPE_OTHER;\r
 \r
   Link = GetFirstNode (&Expression->OpCodeListHead);\r
@@ -1517,7 +1527,7 @@ EvaluateExpression (
 \r
       Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;\r
       Value->Value.u64 = StrLen (StrPtr);\r
-      gBS->FreePool (StrPtr);\r
+      FreePool (StrPtr);\r
       break;\r
 \r
     case EFI_IFR_NOT_OP:\r
@@ -1581,7 +1591,7 @@ EvaluateExpression (
       } else {\r
         Index = (UINT16) Value->Value.u64;\r
         Value->Value.string = Index;\r
-        gBS->FreePool (StrPtr);\r
+        FreePool (StrPtr);\r
       }\r
       break;\r
 \r
@@ -1621,7 +1631,7 @@ EvaluateExpression (
         } else {\r
           Value->Value.b = FALSE;\r
         }\r
-        gBS->FreePool (StrPtr);\r
+        FreePool (StrPtr);\r
         Value->Type = EFI_IFR_TYPE_BOOLEAN;\r
       }\r
       break;\r
@@ -1661,7 +1671,7 @@ EvaluateExpression (
         mUnicodeCollation->StrUpr (mUnicodeCollation, StrPtr);\r
       }\r
       Value->Value.string = NewString (StrPtr, FormSet->HiiHandle);\r
-      gBS->FreePool (StrPtr);\r
+      FreePool (StrPtr);\r
       break;\r
 \r
     case EFI_IFR_BITWISE_NOT_OP:\r