public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when PlatformLang is missing.
@ 2018-05-06  0:07 Marvin Häuser
  2018-05-07 18:10 ` Carsey, Jaben
  2018-05-17  8:00 ` Ni, Ruiyu
  0 siblings, 2 replies; 3+ messages in thread
From: Marvin Häuser @ 2018-05-06  0:07 UTC (permalink / raw)
  To: edk2-devel@lists.01.org; +Cc: jaben.carsey@intel.com, ruiyu.ni@intel.com

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when PlatformLang is missing.
  2018-05-06  0:07 [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when PlatformLang is missing Marvin Häuser
@ 2018-05-07 18:10 ` Carsey, Jaben
  2018-05-17  8:00 ` Ni, Ruiyu
  1 sibling, 0 replies; 3+ messages in thread
From: Carsey, Jaben @ 2018-05-07 18:10 UTC (permalink / raw)
  To: Marvin Häuser, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when PlatformLang is missing.
  2018-05-06  0:07 [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when PlatformLang is missing Marvin Häuser
  2018-05-07 18:10 ` Carsey, Jaben
@ 2018-05-17  8:00 ` Ni, Ruiyu
  1 sibling, 0 replies; 3+ messages in thread
From: Ni, Ruiyu @ 2018-05-17  8:00 UTC (permalink / raw)
  To: Marvin Häuser, edk2-devel@lists.01.org; +Cc: Carsey, Jaben

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-17  8:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-06  0:07 [PATCH] ShellPkg/UefiShellCommandLib: Do not error-exit when PlatformLang is missing Marvin Häuser
2018-05-07 18:10 ` Carsey, Jaben
2018-05-17  8:00 ` Ni, Ruiyu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox