Enhance HiiThunkGetString to handle the case that PlatformLanguage is not set.
authorlgao4 <lgao4@de2fecce-e211-0410-80a6-f3fac2684e05>
Wed, 11 Nov 2009 05:19:30 +0000 (05:19 +0000)
committerlgao4 <lgao4@de2fecce-e211-0410-80a6-f3fac2684e05>
Wed, 11 Nov 2009 05:19:30 +0000 (05:19 +0000)
git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@9408 de2fecce-e211-0410-80a6-f3fac2684e05

edk2/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c

index d83750b..3165f62 100644 (file)
@@ -308,6 +308,9 @@ HiiThunkGetString (
   Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
 \r
   Rfc4646AsciiLanguage = NULL;\r
+  SupportedLanguages   = NULL;\r
+  PlatformLanguage     = NULL;\r
+  Status               = EFI_SUCCESS;\r
 \r
   if (LanguageString != NULL) {\r
     Iso639AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);\r
@@ -328,7 +331,6 @@ HiiThunkGetString (
     // Iso639ToRfc4646Map.\r
     //\r
     ASSERT (Rfc4646AsciiLanguage != NULL);\r
-    \r
   }\r
 \r
   UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);\r
@@ -342,16 +344,13 @@ HiiThunkGetString (
   //\r
   SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);\r
   if (SupportedLanguages == NULL) {\r
-    goto Error2;\r
+    goto Done;\r
   }\r
 \r
   //\r
   // Get the current platform language setting\r
   //\r
   PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang");\r
-  if (PlatformLanguage == NULL) {\r
-    goto Error1;\r
-  }\r
 \r
   //\r
   // Get the best matching language from SupportedLanguages\r
@@ -359,36 +358,38 @@ HiiThunkGetString (
   BestLanguage = GetBestLanguage (\r
                    SupportedLanguages, \r
                    FALSE,                // RFC 4646 mode\r
-                   (Rfc4646AsciiLanguage != NULL) ? Rfc4646AsciiLanguage : "",\r
-                   PlatformLanguage,     // Next highest priority\r
+                   (Rfc4646AsciiLanguage != NULL) ? Rfc4646AsciiLanguage : "", // Highest priority \r
+                   (PlatformLanguage != NULL) ? PlatformLanguage : "",         // Next highest priority\r
                    SupportedLanguages,   // Lowest priority \r
                    NULL\r
                    );\r
-  if (BestLanguage == NULL) {\r
-    FreePool (PlatformLanguage);\r
-Error1:\r
-    FreePool (SupportedLanguages);\r
-Error2:\r
+  if (BestLanguage != NULL) {\r
+    Status = mHiiStringProtocol->GetString (\r
+                                 mHiiStringProtocol,\r
+                                 BestLanguage,\r
+                                 UefiHiiHandle,\r
+                                 Token,\r
+                                 StringBuffer,\r
+                                 BufferLengthTemp,\r
+                                 NULL\r
+                                 );\r
+    FreePool (BestLanguage);\r
+  } else {\r
     Status = EFI_INVALID_PARAMETER;\r
-    goto Done;\r
   }\r
 \r
-  Status = mHiiStringProtocol->GetString (\r
-                               mHiiStringProtocol,\r
-                               BestLanguage,\r
-                               UefiHiiHandle,\r
-                               Token,\r
-                               StringBuffer,\r
-                               BufferLengthTemp,\r
-                               NULL\r
-                               );\r
-  FreePool (BestLanguage);\r
-\r
 Done:\r
        if (Rfc4646AsciiLanguage != NULL) {\r
     FreePool (Rfc4646AsciiLanguage);\r
   }\r
-  \r
+\r
+  if (SupportedLanguages != NULL) {\r
+    FreePool (SupportedLanguages);\r
+  }\r
+\r
+  if (PlatformLanguage != NULL) {\r
+    FreePool (PlatformLanguage);\r
+  }\r
   return Status;\r
 }\r
 \r