From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 85AF121AE30C3 for ; Sat, 3 Jun 2017 17:46:43 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP; 03 Jun 2017 17:47:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,293,1493708400"; d="scan'208";a="864302045" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 03 Jun 2017 17:47:46 -0700 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 3 Jun 2017 17:47:46 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 3 Jun 2017 17:47:46 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.151]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.197]) with mapi id 14.03.0319.002; Sun, 4 Jun 2017 08:47:43 +0800 From: "Ni, Ruiyu" To: "Shah, Tapan" , "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" Thread-Topic: [PATCH] ShellPkg/alias: Fix bug to support upper-case alias Thread-Index: AQHS2ugEjO2x3Mjf7U+DDAKW7Lk49qIQGazggAB6rQD//4/SIIAAAP/wgAC1fNCAAExbAIAAEyqAgAKnsXA= Date: Sun, 4 Jun 2017 00:47:43 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5B9862D6@SHSMSX104.ccr.corp.intel.com> References: <20170601141136.145340-1-ruiyu.ni@intel.com> <734D49CCEBEEF84792F5B80ED585239D5B982065@SHSMSX104.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5B982AEF@SHSMSX104.ccr.corp.intel.com> In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzE2ZmQwNjEtNDUxZi00MTM2LWEzMzktMWJhMTZmNDM1MDU3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlJQNkthdVg5NGVRbElcLzFsQUh3QUs3STN0cjJqcHAyR3EyQXVlZDhWUW9jPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] ShellPkg/alias: Fix bug to support upper-case alias X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Jun 2017 00:46:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable It's the original behavior of alias, not changed by this fix. If you think it's a bug, could you please submit a Bugzilla to record it? Regards, Ray >-----Original Message----- >From: Shah, Tapan [mailto:tapandshah@hpe.com] >Sent: Saturday, June 3, 2017 12:13 AM >To: Carsey, Jaben ; Ni, Ruiyu = ; edk2-devel@lists.01.org >Cc: Kinney, Michael D >Subject: RE: [PATCH] ShellPkg/alias: Fix bug to support upper-case alias > >When attempting to delete an alias that does not exist, it does not retur= n an error in lasterror status indiciating alias was >not found. > >-----Original Message----- >From: Carsey, Jaben [mailto:jaben.carsey@intel.com] >Sent: Friday, June 02, 2017 10:04 AM >To: Ni, Ruiyu ; edk2-devel@lists.01.org >Cc: Kinney, Michael D ; Shah, Tapan >Subject: RE: [PATCH] ShellPkg/alias: Fix bug to support upper-case alias > >Ok. I see now. Thanks! > >Reviewed-by: Jaben Carsey > >> -----Original Message----- >> From: Ni, Ruiyu >> Sent: Thursday, June 01, 2017 7:32 PM >> To: Carsey, Jaben ; edk2-devel@lists.01.org >> Cc: Kinney, Michael D ; Shah, Tapan >> (tapandshah@hpe.com) >> Subject: RE: [PATCH] ShellPkg/alias: Fix bug to support upper-case >> alias >> Importance: High >> >> Jaben, >> Old code also honors the returning status when delete an alias. >> Please check the line I marked as "<----------" in below. >> >> // >> // We must be trying to remove one if Alias is NULL >> // >> if (Alias =3D=3D NULL) { >> // >> // remove an alias (but passed in COMMAND parameter) >> // >> Status =3D (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); >> >> Status =3D (gRT->SetVariable((CHAR16*)Alias, &gShellAliasGuid, >> EFI_VARIABLE_BOOTSERVICE_ACCESS|(Volatile?0:EFI_VARIABLE_NON_VOL >> ATILE), StrSize(Command), (VOID*)Command)); >> } >> >> Regards, >> Ray >> >> >-----Original Message----- >> >From: Carsey, Jaben >> >Sent: Thursday, June 1, 2017 11:42 PM >> >To: Ni, Ruiyu ; edk2-devel@lists.01.org >> >Cc: Kinney, Michael D ; Shah, Tapan >> (tapandshah@hpe.com) >> >Subject: RE: [PATCH] ShellPkg/alias: Fix bug to support upper-case >> >alias >> > >> >I think we have to leave the behavior the same. The spec says this: >> >" If the >> environment variable does not exist and the >> >Value is an empty string, there is no action." >> > >> >I do not think we can change that to an error return without a spec cha= nge. >> > >> >-Jaben >> > >> >> -----Original Message----- >> >> From: Carsey, Jaben >> >> Sent: Thursday, June 01, 2017 8:40 AM >> >> To: Ni, Ruiyu ; edk2-devel@lists.01.org >> >> Cc: Kinney, Michael D ; Shah, Tapan >> >> (tapandshah@hpe.com) >> >> Subject: RE: [PATCH] ShellPkg/alias: Fix bug to support upper-case >> >> alias >> >> >> >> I just think we may want to have the behavior act the same as it >> >> does >> today >> >> for delete. >> >> >> >> > -----Original Message----- >> >> > From: Ni, Ruiyu >> >> > Sent: Thursday, June 01, 2017 8:19 AM >> >> > To: Carsey, Jaben ; >> >> > edk2-devel@lists.01.org >> >> > Cc: Kinney, Michael D ; Shah, Tapan >> >> > (tapandshah@hpe.com) >> >> > Subject: RE: [PATCH] ShellPkg/alias: Fix bug to support >> >> > upper-case alias >> >> > Importance: High >> >> > >> >> > I was using AliasLower. >> >> > I am not sure whether the change is smallest. But I tried best to >> >> > make >> the >> >> > new implementation cleaner. I think that's what we really need. >> >> > >> >> > Did you see any issue if we return EFI_NOT_FOUND (when variable >> doesn't >> >> > exist)? >> >> > >> >> > Regards, >> >> > Ray >> >> > >> >> > >-----Original Message----- >> >> > >From: Carsey, Jaben >> >> > >Sent: Thursday, June 1, 2017 11:02 PM >> >> > >To: Ni, Ruiyu ; edk2-devel@lists.01.org >> >> > >Cc: Kinney, Michael D ; Shah, Tapan >> >> > (tapandshah@hpe.com) >> >> > >Subject: RE: [PATCH] ShellPkg/alias: Fix bug to support >> >> > >upper-case alias >> >> > > >> >> > >Why not just use the AliasLower and make the overall change much >> >> > smaller? Looks like the old version did the conversion, >> >> > >but didn't use the result. >> >> > > >> >> > >Also, I notice that we are now checking the return value upon >> >> > >delete, >> >> which >> >> > was explicitly not done in the old version. >> >> > >There was this comment before: "We dont check the error return >> >> > >on >> >> > purpose since the variable may not exist." >> >> > > >> >> > >-Jaben >> >> > > >> >> > > >> >> > >> -----Original Message----- >> >> > >> From: Ni, Ruiyu >> >> > >> Sent: Thursday, June 01, 2017 7:12 AM >> >> > >> To: edk2-devel@lists.01.org >> >> > >> Cc: Carsey, Jaben ; Kinney, Michael D >> >> > >> >> >> > >> Subject: [PATCH] ShellPkg/alias: Fix bug to support upper-case >> >> > >> alias >> >> > >> Importance: High >> >> > >> >> >> > >> 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 >> >> > >> Cc: Jaben Carsey >> >> > >> Cc: Michael D Kinney >> >> > >> --- >> >> > >> 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 !=3D NULL) { >> >> > >> - AliasLower =3D AllocateCopyPool (StrSize (Alias), Alias); >> >> > >> - if (AliasLower =3D=3D NULL) { >> >> > >> - return EFI_OUT_OF_RESOURCES; >> >> > >> - } >> >> > >> - ToLower (AliasLower); >> >> > >> - } else { >> >> > >> - AliasLower =3D NULL; >> >> > >> - } >> >> > >> - >> >> > >> - // >> >> > >> - // We must be trying to remove one if Alias is NULL >> >> > >> - // >> >> > >> + DeleteAlias =3D FALSE; >> >> > >> if (Alias =3D=3D NULL) { >> >> > >> // >> >> > >> + // We must be trying to remove one if Alias is NULL >> >> > >> // remove an alias (but passed in COMMAND parameter) >> >> > >> // >> >> > >> - Status =3D (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 vari= able >> may >> >> > not >> >> > >> exist. >> >> > >> - gRT->SetVariable((CHAR16*)Command, &gShellAliasGuid, 0, 0, >> >> NULL); >> >> > >> + Alias =3D Command; >> >> > >> + DeleteAlias =3D TRUE; >> >> > >> + } >> >> > >> + ASSERT (Alias !=3D NULL); >> >> > >> >> >> > >> - Status =3D (gRT->SetVariable((CHAR16*)Alias, &gShellAliasGu= id, >> >> > >> >> >> > >> >> >> EFI_VARIABLE_BOOTSERVICE_ACCESS|(Volatile?0:EFI_VARIABLE_NON_VOL >> >> > >> ATILE), StrSize(Command), (VOID*)Command)); >> >> > >> + // >> >> > >> + // Convert to lowercase to make aliases case-insensitive >> >> > >> + // >> >> > >> + AliasLower =3D AllocateCopyPool (StrSize (Alias), Alias); >> >> > >> + if (AliasLower =3D=3D NULL) { >> >> > >> + return EFI_OUT_OF_RESOURCES; >> >> > >> } >> >> > >> + ToLower (AliasLower); >> >> > >> >> >> > >> - if (Alias !=3D NULL) { >> >> > >> - FreePool (AliasLower); >> >> > >> + if (DeleteAlias) { >> >> > >> + Status =3D gRT->SetVariable (AliasLower, &gShellAliasGuid, = 0, 0, >> NULL); >> >> > >> + } else { >> >> > >> + Status =3D 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 >