]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c
MdeModulePkg/DisplayEngineDxe: Refine the coding style
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / InputHandler.c
index a0b87ff7be4157c2d50c07b58582c1b0e9ffe375..732dd2f3de7a070413a8e7a0d98201f0f361e48d 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 - 2015, 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
@@ -227,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
@@ -244,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
@@ -253,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
@@ -264,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
@@ -879,7 +880,6 @@ TheKey2:
         }\r
 \r
         goto EnterCarriageReturn;\r
-        break;\r
 \r
       case SCAN_UP:\r
       case SCAN_DOWN:\r
@@ -980,7 +980,6 @@ EnterCarriageReturn:
       }\r
 \r
       return EFI_SUCCESS;\r
-      break;\r
 \r
     case CHAR_BACKSPACE:\r
       if (ManualInput) {\r
@@ -1447,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