]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Application/UiApp/FrontPage.c
MdeModulePkg: Refine casting expression result to bigger size
[mirror_edk2.git] / MdeModulePkg / Application / UiApp / FrontPage.c
index 50e35971d9e82ab818638fceeeed1764ec3e82b0..adee67a8ac142c4d3c0f7d2016613881c6ca2d3f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   FrontPage routines to handle the callbacks and browser calls\r
 \r
-Copyright (c) 2004 - 2016, 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
@@ -399,7 +399,7 @@ ConvertProcessorToString (
 \r
   if (Base10Exponent >= 6) {\r
     FreqMhz = ProcessorFrequency;\r
-    for (Index = 0; Index < (UINTN) (Base10Exponent - 6); Index++) {\r
+    for (Index = 0; Index < (UINT32) Base10Exponent - 6; Index++) {\r
       FreqMhz *= 10;\r
     }\r
   } else {\r
@@ -408,9 +408,16 @@ ConvertProcessorToString (
   DestMax = 0x20 / sizeof (CHAR16);\r
   StringBuffer = AllocateZeroPool (0x20);\r
   ASSERT (StringBuffer != NULL);\r
-  Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);\r
+  UnicodeValueToStringS (StringBuffer, sizeof (CHAR16) * DestMax, LEFT_JUSTIFY, FreqMhz / 1000, 3);\r
+  Index = StrnLenS (StringBuffer, DestMax);\r
   StrCatS (StringBuffer, DestMax, L".");\r
-  UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);\r
+  UnicodeValueToStringS (\r
+    StringBuffer + Index + 1,\r
+    sizeof (CHAR16) * (DestMax - (Index + 1)),\r
+    PREFIX_ZERO,\r
+    (FreqMhz % 1000) / 10,\r
+    2\r
+    );\r
   StrCatS (StringBuffer, DestMax, L" GHz");\r
   *String = (CHAR16 *) StringBuffer;\r
   return ;\r
@@ -434,7 +441,7 @@ ConvertMemorySizeToString (
 \r
   StringBuffer = AllocateZeroPool (0x24);\r
   ASSERT (StringBuffer != NULL);\r
-  UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 10);\r
+  UnicodeValueToStringS (StringBuffer, 0x24, LEFT_JUSTIFY, MemorySize, 10);\r
   StrCatS (StringBuffer, 0x24 / sizeof (CHAR16), L" MB RAM");\r
 \r
   *String = (CHAR16 *) StringBuffer;\r
@@ -579,7 +586,7 @@ UpdateFrontPageBannerStrings (
   SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
   Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);\r
   while (!EFI_ERROR(Status)) {\r
-    if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {\r
+    if (Record->Type == SMBIOS_TYPE_BIOS_INFORMATION) {\r
       Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;\r
       StrIndex = Type0Record->BiosVersion;\r
       GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);\r
@@ -597,7 +604,7 @@ UpdateFrontPageBannerStrings (
       }\r
     }\r
 \r
-    if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {\r
+    if (Record->Type == SMBIOS_TYPE_SYSTEM_INFORMATION) {\r
       Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;\r
       StrIndex = Type1Record->ProductName;\r
       GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);\r
@@ -606,7 +613,7 @@ UpdateFrontPageBannerStrings (
       FreePool (NewString);\r
     }\r
 \r
-    if ((Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) {\r
+    if ((Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) {\r
       Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;\r
       //\r
       // The information in the record should be only valid when the CPU Socket is populated.\r
@@ -627,7 +634,7 @@ UpdateFrontPageBannerStrings (
       }\r
     }\r
 \r
-    if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {\r
+    if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {\r
       Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;\r
       if (Type19Record->StartingAddress != 0xFFFFFFFF ) {\r
         InstalledMemory += RShiftU64(Type19Record->EndingAddress -\r
@@ -713,7 +720,7 @@ UiSetConsoleMode (
 \r
   if (IsSetupMode) {\r
     //\r
-    // The requried resolution and text mode is setup mode.\r
+    // The required resolution and text mode is setup mode.\r
     //\r
     NewHorizontalResolution = mSetupHorizontalResolution;\r
     NewVerticalResolution   = mSetupVerticalResolution;\r
@@ -769,7 +776,7 @@ UiSetConsoleMode (
             return EFI_SUCCESS;\r
           } else {\r
             //\r
-            // If current text mode is different from requried text mode.  Set new video mode\r
+            // If current text mode is different from required text mode.  Set new video mode\r
             //\r
             for (Index = 0; Index < MaxTextMode; Index++) {\r
               Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);\r
@@ -794,7 +801,7 @@ UiSetConsoleMode (
             }\r
             if (Index == MaxTextMode) {\r
               //\r
-              // If requried text mode is not supported, return error.\r
+              // If required text mode is not supported, return error.\r
               //\r
               FreePool (Info);\r
               return EFI_UNSUPPORTED;\r