]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
MdeModulePkg: Fixed 'variable set but not used' build warning.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / InputHandler.c
index 81190464cb325aa4f4555813139f8593f9366a24..ae783b4ae336a3ba45e7a366f6128c11f64f6051 100644 (file)
@@ -987,48 +987,49 @@ GetSelectionInputPopUp (
   }\r
 \r
   //\r
-  // Prepare HiiValue array\r
+  // Move valid Option to list head.\r
   //\r
-  HiiValueArray = AllocateZeroPool (OptionCount * sizeof (EFI_HII_VALUE));\r
-  ASSERT (HiiValueArray != NULL);\r
-  Link = GetFirstNode (&Question->OptionListHead);\r
-  for (Index = 0; Index < OptionCount; Index++) {\r
-    if (OrderedList) {\r
+  PopUpMenuLines = 0;\r
+  if (OrderedList) {\r
+    //\r
+    // Prepare HiiValue array\r
+    //  \r
+    HiiValueArray = AllocateZeroPool (OptionCount * sizeof (EFI_HII_VALUE));\r
+    ASSERT (HiiValueArray != NULL);\r
+    for (Index = 0; Index < OptionCount; Index++) {\r
       HiiValueArray[Index].Type = ValueType;\r
       HiiValueArray[Index].Value.u64 = GetArrayData (ValueArray, ValueType, Index);\r
-    } else {\r
-      OneOfOption = QUESTION_OPTION_FROM_LINK (Link);\r
-      CopyMem (&HiiValueArray[Index], &OneOfOption->Value, sizeof (EFI_HII_VALUE));\r
-      Link = GetNextNode (&Question->OptionListHead, Link);\r
     }\r
-  }\r
 \r
-  //\r
-  // Move Suppressed Option to list tail\r
-  //\r
-  PopUpMenuLines = 0;\r
-  for (Index = 0; Index < OptionCount; Index++) {\r
-    OneOfOption = ValueToOption (Question, &HiiValueArray[OptionCount - Index - 1]);\r
-    if (OneOfOption == NULL) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
+    for (Index = 0; Index < OptionCount; Index++) {\r
+      OneOfOption = ValueToOption (Question, &HiiValueArray[OptionCount - Index - 1]);\r
+      if (OneOfOption == NULL) {\r
+        return EFI_NOT_FOUND;\r
+      }\r
 \r
-    RemoveEntryList (&OneOfOption->Link);\r
+      RemoveEntryList (&OneOfOption->Link);\r
 \r
-    if ((OneOfOption->SuppressExpression != NULL) &&\r
-        EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) != ExpressFalse) {\r
       //\r
-      // This option is suppressed, insert to tail\r
-      //\r
-      InsertTailList (&Question->OptionListHead, &OneOfOption->Link);\r
-    } else {\r
-      //\r
-      // Insert to head\r
+      // Insert to head.\r
       //\r
       InsertHeadList (&Question->OptionListHead, &OneOfOption->Link);\r
 \r
       PopUpMenuLines++;\r
     }\r
+\r
+    FreePool (HiiValueArray);\r
+  } else {\r
+    Link = GetFirstNode (&Question->OptionListHead);\r
+    for (Index = 0; Index < OptionCount; Index++) {\r
+      OneOfOption = QUESTION_OPTION_FROM_LINK (Link);\r
+      Link = GetNextNode (&Question->OptionListHead, Link);\r
+      if ((OneOfOption->SuppressExpression == NULL) ||\r
+            EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) == ExpressFalse) {\r
+        RemoveEntryList (&OneOfOption->Link);\r
+        InsertHeadList (&Question->OptionListHead, &OneOfOption->Link);\r
+        PopUpMenuLines++;\r
+      }\r
+    }\r
   }\r
 \r
   //\r
@@ -1310,7 +1311,6 @@ TheKey:
           }\r
         }\r
 \r
-        FreePool (HiiValueArray);\r
         return EFI_DEVICE_ERROR;\r
 \r
       default:\r
@@ -1328,6 +1328,12 @@ TheKey:
         Link = GetFirstNode (&Question->OptionListHead);\r
         while (!IsNull (&Question->OptionListHead, Link)) {\r
           OneOfOption = QUESTION_OPTION_FROM_LINK (Link);\r
+          Link = GetNextNode (&Question->OptionListHead, Link);\r
+\r
+          if ((OneOfOption->SuppressExpression != NULL) &&\r
+              EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) != ExpressFalse) {\r
+            continue;\r
+          }\r
 \r
           SetArrayData (ValueArray, ValueType, Index, OneOfOption->Value.Value.u64);\r
 \r
@@ -1335,8 +1341,6 @@ TheKey:
           if (Index > Question->MaxContainers) {\r
             break;\r
           }\r
-\r
-          Link = GetNextNode (&Question->OptionListHead, Link);\r
         }\r
       } else {\r
         ASSERT (CurrentOption != NULL);\r
@@ -1344,7 +1348,6 @@ TheKey:
       }\r
 \r
       gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute);\r
-      FreePool (HiiValueArray);\r
 \r
       Status = ValidateQuestion (Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF);\r
       if (EFI_ERROR (Status)) {\r
@@ -1381,10 +1384,17 @@ WaitForKeyStroke (
 {\r
   EFI_STATUS  Status;\r
 \r
-  do {\r
-    UiWaitForSingleEvent (gST->ConIn->WaitForKey, 0, 0);\r
+  while (TRUE) {\r
     Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key);\r
-  } while (EFI_ERROR(Status));\r
+    if (!EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
 \r
+    if (Status != EFI_NOT_READY) {\r
+      continue;\r
+    }\r
+\r
+    UiWaitForSingleEvent (gST->ConIn->WaitForKey, 0, 0);\r
+  }\r
   return Status;\r
 }\r