]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Refine the check expression result logic.
authorEric Dong <eric.dong@intel.com>
Fri, 18 Apr 2014 06:40:13 +0000 (06:40 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 18 Apr 2014 06:40:13 +0000 (06:40 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Gao, Liming <liming,gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15476 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.h

index d4ab369a4c6c55ec376c69f4d9c59260490e34f4..92a4727b46d49dc1b832db95dd826455dd4be539 100644 (file)
@@ -3280,6 +3280,44 @@ Done:
   return Status;\r
 }\r
 \r
+/**\r
+  Check whether the result is TRUE or FALSE.\r
+  \r
+  For the EFI_HII_VALUE value type is numeric, return TRUE if the\r
+  value is not 0.\r
+\r
+  @param  Result             Input the result data.\r
+\r
+  @retval TRUE               The result is TRUE.\r
+  @retval FALSE              The result is FALSE.\r
+\r
+**/\r
+BOOLEAN\r
+IsTrue (\r
+  IN EFI_HII_VALUE     *Result\r
+  )\r
+{\r
+  switch (Result->Type) {\r
+  case EFI_IFR_TYPE_BOOLEAN:\r
+    return Result->Value.b;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_8:\r
+    return Result->Value.u8 != 0;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_16:\r
+    return Result->Value.u16 != 0;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_32:\r
+    return Result->Value.u32 != 0;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_64:\r
+    return Result->Value.u64 != 0;\r
+\r
+  default:\r
+    return FALSE;\r
+  }\r
+}\r
+\r
 /**\r
   Return the result of the expression list. Check the expression list and \r
   return the highest priority express result.  \r
@@ -3331,8 +3369,7 @@ EvaluateExpressionList (
   //\r
   ReturnVal = ExpressFalse;\r
   for (Index = 0; Index < ExpList->Count; Index++) {\r
-    if (ExpList->Expression[Index]->Result.Type == EFI_IFR_TYPE_BOOLEAN &&\r
-        ExpList->Expression[Index]->Result.Value.b) {\r
+    if (IsTrue (&ExpList->Expression[Index]->Result)) {\r
       switch (ExpList->Expression[Index]->Type) {\r
         case EFI_HII_EXPRESSION_SUPPRESS_IF:\r
           CompareOne = ExpressSuppress;\r
index 920c839956d67a0c25850223e3eddcacb318b427..e806b504b2934fdc4079d02b928dd862f48db7ca 100644 (file)
@@ -1559,11 +1559,7 @@ ParseOpCodes (
             return Status;\r
           }\r
 \r
-          if (CurrentExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN) {\r
-            return EFI_INVALID_PARAMETER;\r
-          }\r
-\r
-          OpCodeDisabled = CurrentExpression->Result.Value.b;\r
+          OpCodeDisabled = IsTrue(&CurrentExpression->Result);\r
         }\r
 \r
         CurrentExpression = NULL;\r
@@ -2512,11 +2508,8 @@ ParseOpCodes (
               return Status;\r
             }\r
 \r
-            if (CurrentExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN) {\r
-              return EFI_INVALID_PARAMETER;\r
-            }\r
+            OpCodeDisabled = IsTrue (&CurrentExpression->Result);\r
 \r
-            OpCodeDisabled = CurrentExpression->Result.Value.b;\r
             //\r
             // DisableIf Expression is only used once and not queued, free it\r
             //\r
index af52f5710333e1286d873f2e311e3cb3e6a29082..fb988d9ed636cceb8611ee2c9b2777a6e42a723d 100644 (file)
@@ -1985,7 +1985,7 @@ ValidateQuestion (
       return Status;\r
     }\r
 \r
-    if ((Expression->Result.Type == EFI_IFR_TYPE_BOOLEAN) && Expression->Result.Value.b) {\r
+    if (IsTrue (&Expression->Result)) {\r
       switch (Type) {\r
       case EFI_HII_EXPRESSION_INCONSISTENT_IF:\r
         BrowserStatus = BROWSER_INCONSISTENT_IF;\r
index cb3cc320bca4135f75ed0104431c32d6397b67a3..5dedda4e91083a3a51a0fb9f252b2b31ddeeffee 100644 (file)
@@ -1711,4 +1711,21 @@ PopupErrorMessage (
   IN CHAR16                *ErrorString\r
   );\r
 \r
+/**\r
+  Check whether the result is TRUE or FALSE.\r
+\r
+  For the EFI_HII_VALUE value type is numeric, return TRUE if the\r
+  value is not 0.\r
+\r
+  @param  Result             Input the result data.\r
+\r
+  @retval TRUE               The result is TRUE.\r
+  @retval FALSE              The result is FALSE.\r
+\r
+**/\r
+BOOLEAN\r
+IsTrue (\r
+  IN EFI_HII_VALUE     *Result\r
+  );\r
+\r
 #endif\r