[edk2] [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when PlatformLang is missing.

Marvin Häuser posted 1 patch 5 years, 10 months ago
Failed in applying to current master (apply log)
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
[edk2] [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when PlatformLang is missing.
Posted by Marvin Häuser 5 years, 10 months ago
Currently, when the PlatformLang variable is missing,
UefiShellCommandLib error-exits. To prevent the entire UEFI Shell
from failing to load over a missing variable, "en-US" is assumed when
the variable location fails.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
---
 ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index 0df252b42036..dfcfd2e0dd54 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -81,9 +81,6 @@ CommandInit(
   CHAR8                           *PlatformLang;
   
   GetEfiGlobalVariable2 (EFI_PLATFORM_LANG_VARIABLE_NAME, (VOID**)&PlatformLang, NULL);
-  if (PlatformLang == NULL) {
-    return EFI_UNSUPPORTED;
-  }
 
   if (gUnicodeCollation == NULL) {
     Status = gBS->LocateHandleBuffer (
@@ -120,7 +117,7 @@ CommandInit(
       BestLanguage = GetBestLanguage (
                        Uc->SupportedLanguages,
                        FALSE,
-                       PlatformLang,
+                       ((PlatformLang != NULL) ? PlatformLang : "en-US"),
                        NULL
                        );
       if (BestLanguage != NULL) {
@@ -132,7 +129,9 @@ CommandInit(
     if (Handles != NULL) {
       FreePool (Handles);
     }
-    FreePool (PlatformLang);
+    if (PlatformLang != NULL) {
+      FreePool (PlatformLang);
+    }
   }
 
   return (gUnicodeCollation == NULL) ? EFI_UNSUPPORTED : EFI_SUCCESS;
-- 
2.17.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when PlatformLang is missing.
Posted by Carsey, Jaben 5 years, 10 months ago
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Marvin Häuser [mailto:Marvin.Haeuser@outlook.com]
> Sent: Saturday, May 05, 2018 5:07 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when
> PlatformLang is missing.
> Importance: High
> 
> Currently, when the PlatformLang variable is missing,
> UefiShellCommandLib error-exits. To prevent the entire UEFI Shell
> from failing to load over a missing variable, "en-US" is assumed when
> the variable location fails.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
> ---
>  ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 9 ++++----
> -
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> index 0df252b42036..dfcfd2e0dd54 100644
> --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> @@ -81,9 +81,6 @@ CommandInit(
>    CHAR8                           *PlatformLang;
> 
>    GetEfiGlobalVariable2 (EFI_PLATFORM_LANG_VARIABLE_NAME,
> (VOID**)&PlatformLang, NULL);
> -  if (PlatformLang == NULL) {
> -    return EFI_UNSUPPORTED;
> -  }
> 
>    if (gUnicodeCollation == NULL) {
>      Status = gBS->LocateHandleBuffer (
> @@ -120,7 +117,7 @@ CommandInit(
>        BestLanguage = GetBestLanguage (
>                         Uc->SupportedLanguages,
>                         FALSE,
> -                       PlatformLang,
> +                       ((PlatformLang != NULL) ? PlatformLang : "en-US"),
>                         NULL
>                         );
>        if (BestLanguage != NULL) {
> @@ -132,7 +129,9 @@ CommandInit(
>      if (Handles != NULL) {
>        FreePool (Handles);
>      }
> -    FreePool (PlatformLang);
> +    if (PlatformLang != NULL) {
> +      FreePool (PlatformLang);
> +    }
>    }
> 
>    return (gUnicodeCollation == NULL) ? EFI_UNSUPPORTED : EFI_SUCCESS;
> --
> 2.17.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when PlatformLang is missing.
Posted by Ni, Ruiyu 5 years, 10 months ago
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Thanks/Ray

> -----Original Message-----
> From: Marvin Häuser <Marvin.Haeuser@outlook.com>
> Sent: Sunday, May 6, 2018 8:07 AM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when
> PlatformLang is missing.
> 
> Currently, when the PlatformLang variable is missing, UefiShellCommandLib
> error-exits. To prevent the entire UEFI Shell from failing to load over a
> missing variable, "en-US" is assumed when the variable location fails.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
> ---
>  ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 9 ++++----
> -
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> index 0df252b42036..dfcfd2e0dd54 100644
> --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> @@ -81,9 +81,6 @@ CommandInit(
>    CHAR8                           *PlatformLang;
> 
>    GetEfiGlobalVariable2 (EFI_PLATFORM_LANG_VARIABLE_NAME,
> (VOID**)&PlatformLang, NULL);
> -  if (PlatformLang == NULL) {
> -    return EFI_UNSUPPORTED;
> -  }
> 
>    if (gUnicodeCollation == NULL) {
>      Status = gBS->LocateHandleBuffer (
> @@ -120,7 +117,7 @@ CommandInit(
>        BestLanguage = GetBestLanguage (
>                         Uc->SupportedLanguages,
>                         FALSE,
> -                       PlatformLang,
> +                       ((PlatformLang != NULL) ? PlatformLang :
> + "en-US"),
>                         NULL
>                         );
>        if (BestLanguage != NULL) {
> @@ -132,7 +129,9 @@ CommandInit(
>      if (Handles != NULL) {
>        FreePool (Handles);
>      }
> -    FreePool (PlatformLang);
> +    if (PlatformLang != NULL) {
> +      FreePool (PlatformLang);
> +    }
>    }
> 
>    return (gUnicodeCollation == NULL) ? EFI_UNSUPPORTED : EFI_SUCCESS;
> --
> 2.17.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel