]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c
MdeModulePkg/RamDiskDxe: fix C string literal catenation in info messages
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / InputHandler.c
index a58e12f12c29ed903e43c92bf91f84d992fcf903..d02c0bf0742433ef5f0ba2187dad22a410539848 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation for handling user input from the User Interfaces.\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -84,6 +84,7 @@ ReadString (
   UINTN                   Maximum;\r
   FORM_DISPLAY_ENGINE_STATEMENT  *Question;\r
   BOOLEAN                 IsPassword;\r
+  UINTN                   MaxLen;\r
 \r
   DimensionsWidth  = gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn;\r
   DimensionsHeight = gStatementDimensions.BottomRow - gStatementDimensions.TopRow;\r
@@ -102,7 +103,8 @@ ReadString (
     IsPassword = FALSE;\r
   }\r
 \r
-  TempString = AllocateZeroPool ((Maximum + 1)* sizeof (CHAR16));\r
+  MaxLen = Maximum + 1;\r
+  TempString = AllocateZeroPool (MaxLen * sizeof (CHAR16));\r
   ASSERT (TempString);\r
 \r
   if (ScreenSize < (Maximum + 1)) {\r
@@ -190,6 +192,13 @@ ReadString (
         gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);\r
         return EFI_DEVICE_ERROR;\r
 \r
+       case SCAN_DELETE:\r
+        for (Index = CurrentCursor; StringPtr[Index] != CHAR_NULL; Index++) {\r
+          StringPtr[Index] = StringPtr[Index + 1];\r
+          PrintCharAt (Start + Index + 1, Top + 3, IsPassword && StringPtr[Index] != CHAR_NULL? L'*' : StringPtr[Index]);\r
+        }\r
+        break;\r
+\r
       default:\r
         break;\r
       }\r
@@ -220,7 +229,6 @@ ReadString (
         return EFI_DEVICE_ERROR;\r
       }\r
 \r
-      break;\r
 \r
     case CHAR_BACKSPACE:\r
       if (StringPtr[0] != CHAR_NULL && CurrentCursor != 0) {\r
@@ -237,7 +245,7 @@ ReadString (
         //\r
         // Effectively truncate string by 1 character\r
         //\r
-        StrCpy (StringPtr, TempString);\r
+        StrCpyS (StringPtr, MaxLen, TempString);\r
         CurrentCursor --;\r
       }\r
 \r
@@ -246,7 +254,7 @@ ReadString (
       // If it is the beginning of the string, don't worry about checking maximum limits\r
       //\r
       if ((StringPtr[0] == CHAR_NULL) && (Key.UnicodeChar != CHAR_BACKSPACE)) {\r
-        StrnCpy (StringPtr, &Key.UnicodeChar, 1);\r
+        StrnCpyS (StringPtr, MaxLen, &Key.UnicodeChar, 1);\r
         CurrentCursor++;\r
       } else if ((GetStringWidth (StringPtr) < ((Maximum + 1) * sizeof (CHAR16))) && (Key.UnicodeChar != CHAR_BACKSPACE)) {\r
         KeyPad[0] = Key.UnicodeChar;\r
@@ -257,11 +265,11 @@ ReadString (
             TempString[Index] = StringPtr[Index];\r
           }\r
                  TempString[Index] = CHAR_NULL;\r
-          StrCat (TempString, KeyPad);\r
-          StrCat (TempString, StringPtr + CurrentCursor);\r
-          StrCpy (StringPtr, TempString);\r
+          StrCatS (TempString, MaxLen, KeyPad);\r
+          StrCatS (TempString, MaxLen, StringPtr + CurrentCursor);\r
+          StrCpyS (StringPtr, MaxLen, TempString);\r
         } else {\r
-          StrCat (StringPtr, KeyPad);\r
+          StrCatS (StringPtr, MaxLen, KeyPad);\r
         }\r
         CurrentCursor++;\r
       }\r
@@ -368,6 +376,9 @@ AdjustQuestionValue (
   Get field info from numeric opcode.\r
 \r
   @param  OpCode            Pointer to the current input opcode.\r
+  @param  IntInput          Whether question shows with EFI_IFR_DISPLAY_INT_DEC type.\r
+  @param  QuestionValue     Input question value, with EFI_HII_VALUE type.\r
+  @param  Value             Return question value, always return UINT64 type.\r
   @param  Minimum           The minimum size info for this opcode.\r
   @param  Maximum           The maximum size info for this opcode.\r
   @param  Step              The step size info for this opcode.\r
@@ -377,6 +388,9 @@ AdjustQuestionValue (
 VOID\r
 GetValueFromNum (\r
   IN  EFI_IFR_OP_HEADER     *OpCode,\r
+  IN  BOOLEAN               IntInput,\r
+  IN  EFI_HII_VALUE         *QuestionValue,\r
+  OUT UINT64                *Value,\r
   OUT UINT64                *Minimum,\r
   OUT UINT64                *Maximum,\r
   OUT UINT64                *Step,\r
@@ -389,29 +403,57 @@ GetValueFromNum (
   \r
   switch (NumericOp->Flags & EFI_IFR_NUMERIC_SIZE) {\r
   case EFI_IFR_NUMERIC_SIZE_1:\r
-    *Minimum = NumericOp->data.u8.MinValue;\r
-    *Maximum = NumericOp->data.u8.MaxValue;\r
+    if (IntInput) {\r
+      *Minimum = (INT64) (INT8) NumericOp->data.u8.MinValue;\r
+      *Maximum = (INT64) (INT8) NumericOp->data.u8.MaxValue;\r
+      *Value   = (INT64) (INT8) QuestionValue->Value.u8;\r
+    } else {\r
+      *Minimum = NumericOp->data.u8.MinValue;\r
+      *Maximum = NumericOp->data.u8.MaxValue;\r
+      *Value   = QuestionValue->Value.u8;\r
+    }\r
     *Step    = NumericOp->data.u8.Step;\r
     *StorageWidth = (UINT16) sizeof (UINT8);\r
     break;\r
   \r
   case EFI_IFR_NUMERIC_SIZE_2:\r
-    *Minimum = NumericOp->data.u16.MinValue;\r
-    *Maximum = NumericOp->data.u16.MaxValue;\r
+    if (IntInput) {\r
+      *Minimum = (INT64) (INT16) NumericOp->data.u16.MinValue;\r
+      *Maximum = (INT64) (INT16) NumericOp->data.u16.MaxValue;\r
+      *Value   = (INT64) (INT16) QuestionValue->Value.u16;\r
+    } else {\r
+      *Minimum = NumericOp->data.u16.MinValue;\r
+      *Maximum = NumericOp->data.u16.MaxValue;\r
+      *Value   = QuestionValue->Value.u16;\r
+    }\r
     *Step    = NumericOp->data.u16.Step;\r
     *StorageWidth = (UINT16) sizeof (UINT16);\r
     break;\r
   \r
   case EFI_IFR_NUMERIC_SIZE_4:\r
-    *Minimum = NumericOp->data.u32.MinValue;\r
-    *Maximum = NumericOp->data.u32.MaxValue;\r
+    if (IntInput) {\r
+      *Minimum = (INT64) (INT32) NumericOp->data.u32.MinValue;\r
+      *Maximum = (INT64) (INT32) NumericOp->data.u32.MaxValue;\r
+      *Value   = (INT64) (INT32) QuestionValue->Value.u32;\r
+    } else {\r
+      *Minimum = NumericOp->data.u32.MinValue;\r
+      *Maximum = NumericOp->data.u32.MaxValue;\r
+      *Value   = QuestionValue->Value.u32;\r
+    }\r
     *Step    = NumericOp->data.u32.Step;\r
     *StorageWidth = (UINT16) sizeof (UINT32);\r
     break;\r
   \r
   case EFI_IFR_NUMERIC_SIZE_8:\r
-    *Minimum = NumericOp->data.u64.MinValue;\r
-    *Maximum = NumericOp->data.u64.MaxValue;\r
+    if (IntInput) {\r
+      *Minimum = (INT64) NumericOp->data.u64.MinValue;\r
+      *Maximum = (INT64) NumericOp->data.u64.MaxValue;\r
+      *Value   = (INT64) QuestionValue->Value.u64;\r
+    } else {\r
+      *Minimum = NumericOp->data.u64.MinValue;\r
+      *Maximum = NumericOp->data.u64.MaxValue;\r
+      *Value   = QuestionValue->Value.u64;\r
+    }\r
     *Step    = NumericOp->data.u64.Step;\r
     *StorageWidth = (UINT16) sizeof (UINT64);\r
     break;\r
@@ -439,7 +481,6 @@ GetNumericInput (
   IN  UI_MENU_OPTION              *MenuOption\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
   UINTN                   Column;\r
   UINTN                   Row;\r
   CHAR16                  InputText[MAX_NUMERIC_INPUT_WIDTH];\r
@@ -449,6 +490,9 @@ GetNumericInput (
   UINTN                   Loop;\r
   BOOLEAN                 ManualInput;\r
   BOOLEAN                 HexInput;\r
+  BOOLEAN                 IntInput;\r
+  BOOLEAN                 Negative;\r
+  BOOLEAN                 ValidateFail;\r
   BOOLEAN                 DateOrTime;\r
   UINTN                   InputWidth;\r
   UINT64                  EditValue;\r
@@ -473,9 +517,14 @@ GetNumericInput (
   Minimum           = 0;\r
   Maximum           = 0;\r
   NumericOp         = NULL;\r
+  IntInput          = FALSE;\r
+  HexInput          = FALSE;\r
+  Negative          = FALSE;\r
+  ValidateFail      = FALSE;\r
 \r
   Question      = MenuOption->ThisTag;\r
   QuestionValue = &Question->CurrentValue;\r
+  ZeroMem (InputText, MAX_NUMERIC_INPUT_WIDTH * sizeof (CHAR16));\r
 \r
   //\r
   // Only two case, user can enter to this function: Enter and +/- case.\r
@@ -569,16 +618,19 @@ GetNumericInput (
   } else {\r
     ASSERT (Question->OpCode->OpCode == EFI_IFR_NUMERIC_OP);\r
     NumericOp = (EFI_IFR_NUMERIC *) Question->OpCode;\r
-    GetValueFromNum(Question->OpCode, &Minimum, &Maximum, &Step, &StorageWidth);\r
-    EditValue = QuestionValue->Value.u64;\r
+    GetValueFromNum(Question->OpCode, (NumericOp->Flags & EFI_IFR_DISPLAY) == 0, QuestionValue, &EditValue, &Minimum, &Maximum, &Step, &StorageWidth);\r
     EraseLen  = gOptionBlockWidth;\r
   }\r
 \r
-  if ((Question->OpCode->OpCode == EFI_IFR_NUMERIC_OP) && (NumericOp != NULL) &&\r
-      ((NumericOp->Flags & EFI_IFR_DISPLAY) == EFI_IFR_DISPLAY_UINT_HEX)) {\r
-    HexInput = TRUE;\r
-  } else {\r
-    HexInput = FALSE;\r
+  if ((Question->OpCode->OpCode == EFI_IFR_NUMERIC_OP) && (NumericOp != NULL)) {\r
+    if ((NumericOp->Flags & EFI_IFR_DISPLAY) == EFI_IFR_DISPLAY_UINT_HEX){\r
+      HexInput = TRUE;\r
+    } else if ((NumericOp->Flags & EFI_IFR_DISPLAY) == 0){\r
+      //\r
+      // Display with EFI_IFR_DISPLAY_INT_DEC type. Support negative number.\r
+      //\r
+      IntInput = TRUE;\r
+    }\r
   }\r
 \r
   //\r
@@ -610,6 +662,13 @@ GetNumericInput (
           InputWidth = 0;\r
           break;\r
         }\r
+\r
+        if (IntInput) {\r
+          //\r
+          // Support an extra '-' for negative number.\r
+          //\r
+          InputWidth += 1;\r
+        }\r
       }\r
 \r
       InputText[0] = LEFT_NUMERIC_DELIMITER;\r
@@ -632,16 +691,17 @@ GetNumericInput (
       if (MenuOption->Sequence == 0) {\r
         InputText[0] = LEFT_NUMERIC_DELIMITER;\r
         SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
-      } else {\r
+        InputText[InputWidth + 1] = DATE_SEPARATOR;\r
+        InputText[InputWidth + 2] = L'\0';\r
+      } else  if (MenuOption->Sequence == 1){\r
         SetUnicodeMem (InputText, InputWidth, L' ');\r
-      }\r
-\r
-      if (MenuOption->Sequence == 2) {\r
-        InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+        InputText[InputWidth] = DATE_SEPARATOR;\r
+        InputText[InputWidth + 1] = L'\0';\r
       } else {\r
-        InputText[InputWidth + 1] = DATE_SEPARATOR;\r
+        SetUnicodeMem (InputText, InputWidth, L' ');\r
+        InputText[InputWidth] = RIGHT_NUMERIC_DELIMITER;\r
+        InputText[InputWidth + 1] = L'\0';\r
       }\r
-      InputText[InputWidth + 2] = L'\0';\r
 \r
       PrintStringAt (Column, Row, InputText);\r
       if (MenuOption->Sequence == 0) {\r
@@ -655,16 +715,17 @@ GetNumericInput (
       if (MenuOption->Sequence == 0) {\r
         InputText[0] = LEFT_NUMERIC_DELIMITER;\r
         SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
-      } else {\r
+        InputText[InputWidth + 1] = TIME_SEPARATOR;\r
+        InputText[InputWidth + 2] = L'\0';\r
+      } else if (MenuOption->Sequence == 1){\r
         SetUnicodeMem (InputText, InputWidth, L' ');\r
-      }\r
-\r
-      if (MenuOption->Sequence == 2) {\r
-        InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+        InputText[InputWidth] = TIME_SEPARATOR;\r
+        InputText[InputWidth + 1] = L'\0';\r
       } else {\r
-        InputText[InputWidth + 1] = TIME_SEPARATOR;\r
+        SetUnicodeMem (InputText, InputWidth, L' ');\r
+        InputText[InputWidth] = RIGHT_NUMERIC_DELIMITER;\r
+        InputText[InputWidth + 1] = L'\0';\r
       }\r
-      InputText[InputWidth + 2] = L'\0';\r
 \r
       PrintStringAt (Column, Row, InputText);\r
       if (MenuOption->Sequence == 0) {\r
@@ -685,20 +746,34 @@ GetNumericInput (
       goto TheKey2;\r
     }\r
 \r
-    Status = WaitForKeyStroke (&Key);\r
+    WaitForKeyStroke (&Key);\r
 \r
 TheKey2:\r
     switch (Key.UnicodeChar) {\r
 \r
     case '+':\r
     case '-':\r
-      if (Key.UnicodeChar == '+') {\r
-        Key.ScanCode = SCAN_RIGHT;\r
+      if (ManualInput && IntInput) {\r
+        //\r
+        // In Manual input mode, check whether input the negative flag.\r
+        //\r
+        if (Key.UnicodeChar == '-') {\r
+          if (Negative) {\r
+            break;\r
+          }\r
+          Negative = TRUE;\r
+          PrintCharAt (Column++, Row, Key.UnicodeChar);\r
+        }\r
       } else {\r
-        Key.ScanCode = SCAN_LEFT;\r
+        if (Key.UnicodeChar == '+') {\r
+          Key.ScanCode = SCAN_RIGHT;\r
+        } else {\r
+          Key.ScanCode = SCAN_LEFT;\r
+        }\r
+        Key.UnicodeChar = CHAR_NULL;\r
+        goto TheKey2;\r
       }\r
-      Key.UnicodeChar = CHAR_NULL;\r
-      goto TheKey2;\r
+      break;\r
 \r
     case CHAR_NULL:\r
       switch (Key.ScanCode) {\r
@@ -716,20 +791,40 @@ TheKey2:
 \r
         if ((Step != 0) && !ManualInput) {\r
           if (Key.ScanCode == SCAN_LEFT) {\r
-            if (EditValue >= Minimum + Step) {\r
-              EditValue = EditValue - Step;\r
-            } else if (EditValue > Minimum){\r
-              EditValue = Minimum;\r
+            if (IntInput) {\r
+              if ((INT64) EditValue >= (INT64) Minimum + (INT64) Step) {\r
+                EditValue = EditValue - Step;\r
+              } else if ((INT64) EditValue > (INT64) Minimum){\r
+                EditValue = Minimum;\r
+              } else {\r
+                EditValue = Maximum;\r
+              }\r
             } else {\r
-              EditValue = Maximum;\r
+              if (EditValue >= Minimum + Step) {\r
+                EditValue = EditValue - Step;\r
+              } else if (EditValue > Minimum){\r
+                EditValue = Minimum;\r
+              } else {\r
+                EditValue = Maximum;\r
+              }\r
             }\r
           } else if (Key.ScanCode == SCAN_RIGHT) {\r
-            if (EditValue + Step <= Maximum) {\r
-              EditValue = EditValue + Step;\r
-            } else if (EditValue < Maximum) {\r
-              EditValue = Maximum;\r
+            if (IntInput) {\r
+              if ((INT64) EditValue + (INT64) Step <= (INT64) Maximum) {\r
+                EditValue = EditValue + Step;\r
+              } else if ((INT64) EditValue < (INT64) Maximum) {\r
+                EditValue = Maximum;\r
+              } else {\r
+                EditValue = Minimum;\r
+              }\r
             } else {\r
-              EditValue = Minimum;\r
+              if (EditValue + Step <= Maximum) {\r
+                EditValue = EditValue + Step;\r
+              } else if (EditValue < Maximum) {\r
+                EditValue = Maximum;\r
+              } else {\r
+                EditValue = Minimum;\r
+              }\r
             }\r
           }\r
 \r
@@ -788,7 +883,6 @@ TheKey2:
         }\r
 \r
         goto EnterCarriageReturn;\r
-        break;\r
 \r
       case SCAN_UP:\r
       case SCAN_DOWN:\r
@@ -809,13 +903,29 @@ EnterCarriageReturn:
       //\r
       // Validate input value with Minimum value.\r
       //\r
-      if (EditValue < Minimum) {\r
+      ValidateFail = FALSE;\r
+      if (IntInput) {\r
+        //\r
+        // After user input Enter, need to check whether the input value.\r
+        // If input a negative value, should compare with maximum value. \r
+        // else compare with the minimum value.\r
+        //\r
+        if (Negative) {\r
+          ValidateFail = (INT64) EditValue > (INT64) Maximum ? TRUE : FALSE;\r
+        } else {\r
+          ValidateFail = (INT64) EditValue < (INT64) Minimum ? TRUE : FALSE;\r
+        }\r
+\r
+        if (ValidateFail) {\r
+          UpdateStatusBar (INPUT_ERROR, TRUE);\r
+          break;\r
+        }\r
+      } else if (EditValue < Minimum) {\r
         UpdateStatusBar (INPUT_ERROR, TRUE);\r
         break;\r
-      } else {\r
-        UpdateStatusBar (INPUT_ERROR, FALSE);\r
       }\r
-      \r
+\r
+      UpdateStatusBar (INPUT_ERROR, FALSE);\r
       CopyMem (&gUserInput->InputValue, &Question->CurrentValue, sizeof (EFI_HII_VALUE));\r
       QuestionValue = &gUserInput->InputValue;\r
       //\r
@@ -872,12 +982,16 @@ EnterCarriageReturn:
         AdjustQuestionValue (QuestionValue, (UINT8)MenuOption->Sequence);\r
       }\r
 \r
-      return ValidateQuestion (Question);\r
-      break;\r
+      return EFI_SUCCESS;\r
 \r
     case CHAR_BACKSPACE:\r
       if (ManualInput) {\r
         if (Count == 0) {\r
+          if (Negative) {\r
+            Negative = FALSE;\r
+            Column--;\r
+            PrintStringAt (Column, Row, L" ");\r
+          }\r
           break;\r
         }\r
         //\r
@@ -923,28 +1037,59 @@ EnterCarriageReturn:
         if (Count != 0) {\r
           if (HexInput) {\r
             EditValue = LShiftU64 (EditValue, 4) + Digital;\r
+          } else if (IntInput && Negative) {\r
+            //\r
+            // Save the negative number.\r
+            //\r
+            EditValue = ~(MultU64x32 (~(EditValue - 1), 10) + (Key.UnicodeChar - L'0')) + 1;\r
           } else {\r
             EditValue = MultU64x32 (EditValue, 10) + (Key.UnicodeChar - L'0');\r
           }\r
         } else {\r
           if (HexInput) {\r
             EditValue = Digital;\r
+          } else if (IntInput && Negative) {\r
+            //\r
+            // Save the negative number.\r
+            //\r
+            EditValue = ~(Key.UnicodeChar - L'0') + 1;\r
           } else {\r
             EditValue = Key.UnicodeChar - L'0';\r
           }\r
         }\r
 \r
-        if (EditValue > Maximum) {\r
-          UpdateStatusBar (INPUT_ERROR, TRUE);\r
-          ASSERT (Count < sizeof (PreviousNumber) / sizeof (PreviousNumber[0]));\r
-          EditValue = PreviousNumber[Count];\r
-          break;\r
+        if (IntInput) {\r
+          ValidateFail = FALSE;\r
+          //\r
+          // When user input a new value, should check the current value.\r
+          // If user input a negative value, should compare it with minimum\r
+          // value, else compare it with maximum value.\r
+          //\r
+          if (Negative) {\r
+            ValidateFail = (INT64) EditValue < (INT64) Minimum ? TRUE : FALSE;\r
+          } else {\r
+            ValidateFail = (INT64) EditValue > (INT64) Maximum ? TRUE : FALSE;\r
+          }\r
+\r
+          if (ValidateFail) {\r
+            UpdateStatusBar (INPUT_ERROR, TRUE);\r
+            ASSERT (Count < ARRAY_SIZE (PreviousNumber));\r
+            EditValue = PreviousNumber[Count];\r
+            break;\r
+          }\r
         } else {\r
-          UpdateStatusBar (INPUT_ERROR, FALSE);\r
+          if (EditValue > Maximum) {\r
+            UpdateStatusBar (INPUT_ERROR, TRUE);\r
+            ASSERT (Count < ARRAY_SIZE (PreviousNumber));\r
+            EditValue = PreviousNumber[Count];\r
+            break;\r
+          }\r
         }\r
 \r
+        UpdateStatusBar (INPUT_ERROR, FALSE);\r
+\r
         Count++;\r
-        ASSERT (Count < (sizeof (PreviousNumber) / sizeof (PreviousNumber[0])));\r
+        ASSERT (Count < (ARRAY_SIZE (PreviousNumber)));\r
         PreviousNumber[Count] = EditValue;\r
 \r
         gST->ConOut->SetAttribute (gST->ConOut, GetHighlightTextColor ());\r
@@ -1118,7 +1263,6 @@ GetSelectionInputPopUp (
   IN  UI_MENU_OPTION              *MenuOption\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
   EFI_INPUT_KEY           Key;\r
   UINTN                   Index;\r
   CHAR16                  *StringPtr;\r
@@ -1158,9 +1302,6 @@ GetSelectionInputPopUp (
   ShowDownArrow     = FALSE;\r
   ShowUpArrow       = FALSE;\r
 \r
-  StringPtr = AllocateZeroPool ((gOptionBlockWidth + 1) * 2);\r
-  ASSERT (StringPtr);\r
-\r
   ZeroMem (&HiiValue, sizeof (EFI_HII_VALUE));\r
 \r
   Question = MenuOption->ThisTag;\r
@@ -1305,7 +1446,7 @@ GetSelectionInputPopUp (
         CopyMem (TempStringPtr, StringPtr, (sizeof (CHAR16) * (PopUpWidth - 5)));\r
         FreePool (StringPtr);\r
         StringPtr = TempStringPtr;\r
-        StrCat (StringPtr, L"...");\r
+        StrCatS (StringPtr, PopUpWidth - 1, L"...");\r
       }\r
 \r
       if (Index == HighlightOptionIndex) {\r
@@ -1351,7 +1492,7 @@ GetSelectionInputPopUp (
       goto TheKey;\r
     }\r
 \r
-    Status = WaitForKeyStroke (&Key);\r
+    WaitForKeyStroke (&Key);\r
 \r
 TheKey:\r
     switch (Key.UnicodeChar) {\r
@@ -1505,7 +1646,6 @@ TheKey:
         } else {\r
           gUserInput->InputValue.Buffer = ReturnValue;\r
           gUserInput->InputValue.BufferLen = Question->CurrentValue.BufferLen;\r
-          Status = EFI_SUCCESS;\r
         }\r
       } else {\r
         ASSERT (CurrentOption != NULL);\r
@@ -1514,13 +1654,12 @@ TheKey:
           return EFI_DEVICE_ERROR;\r
         } else {\r
           SetValuesByType (&gUserInput->InputValue.Value, &CurrentOption->OptionOpCode->Value, gUserInput->InputValue.Type);\r
-          Status = EFI_SUCCESS;\r
         }\r
       }\r
 \r
       gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute);\r
 \r
-      return ValidateQuestion (Question);\r
+      return EFI_SUCCESS;\r
       \r
     default:\r
       break;\r