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>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Tapan Shah <tapandshah@hpe.com>
{\r
EFI_STATUS Status;\r
CHAR16 *AliasLower;\r
{\r
EFI_STATUS Status;\r
CHAR16 *AliasLower;\r
- // Convert to lowercase to make aliases case-insensitive\r
- if (Alias != NULL) {\r
- AliasLower = AllocateCopyPool (StrSize (Alias), Alias);\r
- if (AliasLower == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- ToLower (AliasLower);\r
- } else {\r
- AliasLower = NULL;\r
- }\r
-\r
- //\r
- // We must be trying to remove one if Alias is NULL\r
- //\r
if (Alias == NULL) {\r
//\r
if (Alias == NULL) {\r
//\r
+ // We must be trying to remove one if Alias is NULL\r
// remove an alias (but passed in COMMAND parameter)\r
//\r
// remove an alias (but passed in COMMAND parameter)\r
//\r
- Status = (gRT->SetVariable((CHAR16*)Command, &gShellAliasGuid, 0, 0, NULL));\r
- } else {\r
- //\r
- // Add and replace are the same\r
- //\r
-\r
- // We dont check the error return on purpose since the variable may not exist.\r
- gRT->SetVariable((CHAR16*)Command, &gShellAliasGuid, 0, 0, NULL);\r
+ Alias = Command;\r
+ DeleteAlias = TRUE;\r
+ }\r
+ ASSERT (Alias != NULL);\r
- Status = (gRT->SetVariable((CHAR16*)Alias, &gShellAliasGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS|(Volatile?0:EFI_VARIABLE_NON_VOLATILE), StrSize(Command), (VOID*)Command));\r
+ //\r
+ // Convert to lowercase to make aliases case-insensitive\r
+ //\r
+ AliasLower = AllocateCopyPool (StrSize (Alias), Alias);\r
+ if (AliasLower == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ ToLower (AliasLower);\r
- if (Alias != NULL) {\r
- FreePool (AliasLower);\r
+ if (DeleteAlias) {\r
+ Status = gRT->SetVariable (AliasLower, &gShellAliasGuid, 0, 0, NULL);\r
+ } else {\r
+ Status = gRT->SetVariable (\r
+ AliasLower, &gShellAliasGuid,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | (Volatile ? 0 : EFI_VARIABLE_NON_VOLATILE),\r
+ StrSize (Command), (VOID *) Command\r
+ );\r
+\r
+ FreePool (AliasLower);\r
+\r