]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Library/EdkIfrSupportLib/IfrCommon.c
Partially make EdkModulePkg pass intel IPF compiler with /W4 /WX switched on.
[mirror_edk2.git] / EdkModulePkg / Library / EdkIfrSupportLib / IfrCommon.c
index 6d0a84de5e2ae63d270865e1c229f8c61c31b471..b2c906476de3063416002f194265ada25db37fce 100644 (file)
@@ -1,12 +1,12 @@
 /*++\r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. 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
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
 http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+        \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 Module Name:\r
   IfrCommon.c\r
@@ -20,6 +20,7 @@ Revision History:
 --*/\r
 \r
 EFI_STATUS\r
+EFIAPI\r
 IfrLibConstruct (\r
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
@@ -37,12 +38,12 @@ GetCurrentLanguage (
 Routine Description:\r
 \r
   Determine what is the current language setting\r
-  \r
+\r
 Arguments:\r
-  \r
+\r
   Lang      - Pointer of system language\r
-  \r
-Returns: \r
+\r
+Returns:\r
 \r
   Status code\r
 \r
@@ -70,7 +71,7 @@ Returns:
     AsciiStrCpy (Language, "eng");\r
   }\r
 \r
-  for (Index = 0; Language[Index] != 0; Index++) {\r
+  for (Index = 0; Index < 3; Index++) {\r
     //\r
     // Bitwise AND ascii value with 0xDF yields an uppercase value.\r
     // Sign extend into a unicode value\r
@@ -99,21 +100,21 @@ AddString (
 Routine Description:\r
 \r
   Add a string to the incoming buffer and return the token and offset data\r
-  \r
+\r
 Arguments:\r
-  \r
+\r
   StringBuffer      - The incoming buffer\r
-  \r
+\r
   Language          - Currrent language\r
-  \r
+\r
   String            - The string to be added\r
-  \r
+\r
   StringToken       - The index where the string placed\r
-  \r
-Returns: \r
+\r
+Returns:\r
 \r
   EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
-  \r
+\r
   EFI_SUCCESS             - String successfully added to the incoming buffer\r
 \r
 --*/\r
@@ -127,6 +128,8 @@ Returns:
   UINT8               *Destination;\r
   UINTN               Index;\r
   BOOLEAN             Finished;\r
+  UINTN               SizeofLanguage;\r
+  UINTN               SizeofString;\r
 \r
   StringPack  = (EFI_HII_STRING_PACK *) StringBuffer;\r
   Finished    = FALSE;\r
@@ -171,11 +174,11 @@ Returns:
         //\r
         PackDestination[Index] = (UINT16) (PackDestination[Index] + sizeof (RELOFST));\r
       }\r
-      \r
+\r
       //\r
       // Add a new stringpointer in the new buffer since we are adding a string.  Null terminate it\r
       //\r
-      PackDestination[Index] = (UINT16)(PackDestination[Index-1] + \r
+      PackDestination[Index] = (UINT16)(PackDestination[Index-1] +\r
                                         StrSize((CHAR16 *)((CHAR8 *)(StringPack) + PackSource[Index-1])));\r
       PackDestination[Index + 1] = (UINT16) 0;\r
 \r
@@ -206,7 +209,7 @@ Returns:
         Destination = Destination + StrSize ((CHAR16 *) Source);\r
         Source      = Source + StrSize ((CHAR16 *) Source);\r
       }\r
-      \r
+\r
       //\r
       // This copies the new string to the destination buffer\r
       //\r
@@ -238,7 +241,7 @@ Returns:
     StringPackBuffer  = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPack->Header.Length);\r
     StringPack        = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length);\r
   }\r
-  \r
+\r
   //\r
   // If we didn't copy the new data to a stringpack yet\r
   //\r
@@ -247,14 +250,16 @@ Returns:
     //\r
     // Pointing to a new string pack location\r
     //\r
+    SizeofLanguage = StrSize (Language);\r
+    SizeofString   = StrSize (String);\r
     StringPackBuffer->Header.Length = (UINT32)\r
       (\r
         sizeof (EFI_HII_STRING_PACK) -\r
         sizeof (EFI_STRING) +\r
         sizeof (RELOFST) +\r
         sizeof (RELOFST) +\r
-        StrSize (Language) +\r
-        StrSize (String)\r
+        SizeofLanguage +\r
+        SizeofString\r
       );\r
     StringPackBuffer->Header.Type           = EFI_HII_STRING;\r
     StringPackBuffer->LanguageNameString    = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer);\r
@@ -316,17 +321,17 @@ AddOpCode (
 Routine Description:\r
 \r
   Add op-code data to the FormBuffer\r
-  \r
+\r
 Arguments:\r
-  \r
+\r
   FormBuffer      - Form buffer to be inserted to\r
-  \r
+\r
   OpCodeData      - Op-code data to be inserted\r
-  \r
-Returns: \r
+\r
+Returns:\r
 \r
   EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
-  \r
+\r
   EFI_SUCCESS             - Op-code data successfully inserted\r
 \r
 --*/\r
@@ -422,7 +427,7 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
+STATIC\r
 EFI_STATUS\r
 GetHiiInterface (\r
   OUT     EFI_HII_PROTOCOL    **Hii\r
@@ -432,12 +437,12 @@ GetHiiInterface (
 Routine Description:\r
 \r
   Get the HII protocol interface\r
-  \r
+\r
 Arguments:\r
-  \r
+\r
   Hii     - HII protocol interface\r
-  \r
-Returns: \r
+\r
+Returns:\r
 \r
   Status code\r
 \r
@@ -470,27 +475,27 @@ ExtractDataFromHiiHandle (
 Routine Description:\r
 \r
   Extract information pertaining to the HiiHandle\r
-  \r
+\r
 Arguments:\r
-  \r
+\r
   HiiHandle       - Hii handle\r
-  \r
+\r
   ImageLength     - For input, length of DefaultImage;\r
                     For output, length of actually required\r
-                    \r
+\r
   DefaultImage    - Image buffer prepared by caller\r
-  \r
+\r
   Guid            - Guid information about the form\r
-  \r
-Returns: \r
+\r
+Returns:\r
 \r
   EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
-  \r
+\r
   EFI_BUFFER_TOO_SMALL    - DefualtImage has no enough ImageLength\r
-  \r
+\r
   EFI_SUCCESS             - Successfully extract data from Hii database.\r
-  \r
-  \r
+\r
+\r
 --*/\r
 {\r
   EFI_STATUS        Status;\r
@@ -581,7 +586,7 @@ Returns:
 \r
     Index = RawData[Index + 1] + Index;\r
   }\r
-    \r
+\r
   //\r
   // Return an error if buffer is too small\r
   //\r
@@ -649,9 +654,9 @@ Routine Description:
   Finds HII handle for given pack GUID previously registered with the HII.\r
 \r
 Arguments:\r
-  HiiProtocol - pointer to pointer to HII protocol interface. \r
+  HiiProtocol - pointer to pointer to HII protocol interface.\r
                 If NULL, the interface will be found but not returned.\r
-                If it points to NULL, the interface will be found and \r
+                If it points to NULL, the interface will be found and\r
                 written back to the pointer that is pointed to.\r
   Guid        - The GUID of the pack that registered with the HII.\r
 \r
@@ -766,7 +771,7 @@ Routine Description:
   Validate that the data associated with the HiiHandle in NVRAM is within\r
   the reasonable parameters for that FormSet.  Values for strings and passwords\r
   are not verified due to their not having the equivalent of valid range settings.\r
-  \r
+\r
 Arguments:\r
 \r
   HiiHandle -   Handle of the HII database entry to query\r
@@ -774,11 +779,11 @@ Arguments:
   Results -     If return Status is EFI_SUCCESS, Results provides valid data\r
                 TRUE  = NVRAM Data is within parameters\r
                 FALSE = NVRAM Data is NOT within parameters\r
-  \r
-Returns: \r
+\r
+Returns:\r
 \r
   EFI_OUT_OF_RESOURCES      - No enough buffer to allocate\r
-  \r
+\r
   EFI_SUCCESS               - Data successfully validated\r
 --*/\r
 {\r
@@ -880,7 +885,7 @@ Returns:
 \r
     Index = RawData[Index + 1] + Index;\r
   }\r
-    \r
+\r
   //\r
   // Allocate memory for our File Form Tags\r
   //\r