From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Carsey, Jaben" <jaben.carsey@intel.com>,
"Kinney, Michael D" <michael.d.kinney@intel.com>,
"Shah, Tapan" <tapandshah@hpe.com>
Subject: Re: [PATCH] ShellPkg/alias: Fix bug to support upper-case alias
Date: Thu, 1 Jun 2017 14:14:38 +0000 [thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5B981323@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20170601141136.145340-1-ruiyu.ni@intel.com>
Including Tapan for review.
Thanks/Ray
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Thursday, June 1, 2017 10:12 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: [edk2] [PATCH] ShellPkg/alias: Fix bug to support upper-case alias
>
> alias in UEFI Shell is case insensitive.
> Old code saves the alias to variable storage without converting the alias to
> lower-case, which results upper case alias setting doesn't work.
> The patch converts the alias to lower case before saving to variable storage.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> ---
> ShellPkg/Application/Shell/ShellProtocol.c | 50 +++++++++++++++-------------
> --
> 1 file changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/ShellPkg/Application/Shell/ShellProtocol.c
> b/ShellPkg/Application/Shell/ShellProtocol.c
> index 347e162e62..b3b8acc0d0 100644
> --- a/ShellPkg/Application/Shell/ShellProtocol.c
> +++ b/ShellPkg/Application/Shell/ShellProtocol.c
> @@ -3463,40 +3463,40 @@ InternalSetAlias( {
> EFI_STATUS Status;
> CHAR16 *AliasLower;
> + BOOLEAN DeleteAlias;
>
> - // Convert to lowercase to make aliases case-insensitive
> - if (Alias != NULL) {
> - AliasLower = AllocateCopyPool (StrSize (Alias), Alias);
> - if (AliasLower == NULL) {
> - return EFI_OUT_OF_RESOURCES;
> - }
> - ToLower (AliasLower);
> - } else {
> - AliasLower = NULL;
> - }
> -
> - //
> - // We must be trying to remove one if Alias is NULL
> - //
> + DeleteAlias = FALSE;
> if (Alias == NULL) {
> //
> + // We must be trying to remove one if Alias is NULL
> // remove an alias (but passed in COMMAND parameter)
> //
> - Status = (gRT->SetVariable((CHAR16*)Command, &gShellAliasGuid, 0, 0,
> NULL));
> - } else {
> - //
> - // Add and replace are the same
> - //
> -
> - // We dont check the error return on purpose since the variable may not
> exist.
> - gRT->SetVariable((CHAR16*)Command, &gShellAliasGuid, 0, 0, NULL);
> + Alias = Command;
> + DeleteAlias = TRUE;
> + }
> + ASSERT (Alias != NULL);
>
> - Status = (gRT->SetVariable((CHAR16*)Alias, &gShellAliasGuid,
> EFI_VARIABLE_BOOTSERVICE_ACCESS|(Volatile?0:EFI_VARIABLE_NON_VOL
> ATILE), StrSize(Command), (VOID*)Command));
> + //
> + // Convert to lowercase to make aliases case-insensitive //
> + AliasLower = AllocateCopyPool (StrSize (Alias), Alias); if
> + (AliasLower == NULL) {
> + return EFI_OUT_OF_RESOURCES;
> }
> + ToLower (AliasLower);
>
> - if (Alias != NULL) {
> - FreePool (AliasLower);
> + if (DeleteAlias) {
> + Status = gRT->SetVariable (AliasLower, &gShellAliasGuid, 0, 0,
> + NULL); } else {
> + Status = gRT->SetVariable (
> + AliasLower, &gShellAliasGuid,
> + EFI_VARIABLE_BOOTSERVICE_ACCESS | (Volatile ? 0 :
> EFI_VARIABLE_NON_VOLATILE),
> + StrSize (Command), (VOID *) Command
> + );
> }
> +
> + FreePool (AliasLower);
> +
> return Status;
> }
>
> --
> 2.12.2.windows.2
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
next prev parent reply other threads:[~2017-06-01 14:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-01 14:11 [PATCH] ShellPkg/alias: Fix bug to support upper-case alias Ruiyu Ni
2017-06-01 14:14 ` Ni, Ruiyu [this message]
2017-06-01 15:01 ` Carsey, Jaben
2017-06-01 15:18 ` Ni, Ruiyu
2017-06-01 15:39 ` Carsey, Jaben
2017-06-01 15:42 ` Carsey, Jaben
2017-06-02 2:31 ` Ni, Ruiyu
2017-06-02 15:04 ` Carsey, Jaben
2017-06-02 16:12 ` Shah, Tapan
2017-06-04 0:47 ` Ni, Ruiyu
2017-06-05 15:25 ` Shah, Tapan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=734D49CCEBEEF84792F5B80ED585239D5B981323@SHSMSX104.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox